+92 332 4229 857 99ProjectIdeas@Gmail.com

String Substring Function (C#.net)




Finding a substring in specified string.







For example:

string strOne = "Charm strikes the sight but merit wins the soul";
       string strNew = strOne.Substring(10);
       MessageBox.Show(strNew);

Output:
               Kes the sight but merit wins soul (substring from 10th index to onwards)
               
       
Another example:

string strOne = "Charm strikes the sight but merit wins the soul";
       string strNew = strOne.Substring(5,9);
       MessageBox.Show(strNew);
      

Output:
   Strikes (because from 5th index to 9th is a word “strikes”)

0 comments: