Breaking News
Loading...
Saturday 23 February 2013

How to use Contains method in c#.net

Contains :

"This methode will return true if your specified string is mathes in given string or return false "

How to Use :


       
     bool strmain.Contains(" string strsub")
     

Input Parameter :

         strsub = (string)
 

Output Parameter :

         strmain = (string)


Example  :: 

/////////////////////////  CODE   /////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Contains
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = null;
            str = "Nirav daraniya is app developer";
            if (str.Contains("app") == true)
            {
                MessageBox.Show("The string Contains 'app' ");
            }
            else
            {
                MessageBox.Show("The String is not Contains 'app'");
            }
        }
    }
}



////////////////////////////////  OUTPUT   //////////////////////////////

The string Contains 'app'

//////////////////////////////////////////////////////////////////////////////////



--
/\/ir@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer