Tuesday, July 21, 2009

String Functions in .NET

String manipulations are keenly important for many applications – converting strings to display formats, for instance, or extracting substrings from existing strings.

The String class exposes a variety of member methods for the manipulations of strings.

Some useful string methods in .NET Framework are:

Name                    Description

String.Insert             Inserts a specified string into the current instance

String.PadLeft          Adds characters to the left of the string

String.PadRight        Adds characters to the right of the string

String.Remove          Deletes a specified number of characters from the string, beginning at a specified character

String.Replace          Replaces all occurrences of a specified character in the string with another specified character

String.Split               Returns the array of substrings that are delimited by a specified character

String.Substring        Returns a substring from the specified instance

String.ToCharArray    Returns an array of the characters that make up the string

String.ToLower          Returns the string converted to all lower case

String.ToUpper          Returns the string converted to all upper case

String.TrimEnd          Removes trailing spaces from the string

String.TrimStart         Removes leading spaces from the string

String.Trim                Removes both trailing and leading spaces from the string

String.Compare         Compares two specified string objects

String.Concat            Returns a string that is a result of the concatenation of two or more strings

String.Format            Returns a string that has been formatted according to a specified format

String.Join                Returns a string that is the result of the concatenation of a specified array of strings, with a specified   separation string between each member of the array

No comments:

Post a Comment