Friday 24 August 2012

Substring() in C#

Example On String Substring() method.


Substring in C# string Class returns a new string that is a substring of this string. The substring begins at the specified given index and extended up to the given length.

Syntax : string string.substring(int startIndex,int length)


Parameters:

startIndex: The index of the start of the substring.
length: The number of characters in the substring.



public class SubstringExample
      {
            public static void Main()
            {                
                  string str = null;
                  string SubStr = null;
                  str = "Dotnet Masty Substring Example";
                  SubStr = str.Substring(7, 15);

                  Console.WriteLine(SubStr);               
                  Console.ReadLine();
            }
      }

1 comment: