In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about the properties and methods of the String class in C#. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Properties of the String class
The String class has two properties:
Serial number attribute name & description 1Chars
Gets the specified location of the Char object in the current String object. 2Length
Gets the number of characters in the current String object. Methods of the String class
The String class has many methods for manipulating string objects. The following table provides some of the most common methods:
Serial number method name & description 1public static int Compare (string strA, string strB)
Compares two specified string objects and returns an integer that represents their relative position in the sort order. This method is case sensitive. 2public static int Compare (string strA, string strB, bool ignoreCase)
Compares two specified string objects and returns an integer that represents their relative position in the sort order. However, if the Boolean parameter is true, the method is case-insensitive. 3public static string Concat (string str0, string str1)
Connect two string objects. 4public static string Concat (string str0, string str1, string str2)
Connect three string objects. 5public static string Concat (string str0, string str1, string str2, string str3)
Connect four string objects. 6public bool Contains (string value)
Returns a value indicating whether the specified string object appears in the string. 7public static string Copy (string str)
Creates a new String object with the same value as the specified string. 8public void CopyTo (int sourceIndex, char [] destination, int destinationIndex, int count)
Copies the specified number of characters from the specified location of the string object to the specified position in the Unicode character array. 9public bool EndsWith (string value)
Determines whether the end of the string object matches the specified string. 10public bool Equals (string value)
Determines whether the current string object has the same value as the specified string object. 11public static bool Equals (string a, string b)
Determines whether two specified string objects have the same value. 12public static string Format (string format, Object arg0)
Replaces one or more format items in the specified string with the string representation of the specified object. 13public int IndexOf (char value)
Returns the index of the first occurrence of the specified Unicode character in the current string, starting at 0. 14public int IndexOf (string value)
Returns the index of the first occurrence of the specified string in the instance, starting at 0. 15public int IndexOf (char value, int startIndex)
Returns the specified Unicode character to search for the first occurrence of the index from the specified character position in the string, starting at 0. 16public int IndexOf (string value, int startIndex)
Returns the specified string to search for the first occurrence of the index from the specified character position in the instance, starting at 0. 17public int IndexOfAny (char [] anyOf)
Returns the index of any character in a specified Unicode character array that appears for the first time in this instance, starting at 0. 18public int IndexOfAny (char [] anyOf, int startIndex)
Returns any character in a specified Unicode character array to search for the first occurrence of the index from the specified character position in the instance, starting at 0. 19public string Insert (int startIndex, string value)
Returns a new string in which the specified string is inserted at the specified index of the current string object. 20public static bool IsNullOrEmpty (string value)
Indicates whether the specified string is null or an empty string. 21public static string Join (string separator, string [] value)
Concatenates all elements in a string array, separating each element with the specified delimiter. 22public static string Join (string separator, string [] value, int startIndex, int count)
Concatenates the specified elements starting at the specified position in a string array, separating each element with the specified delimiter. 23public int LastIndexOf (char value)
Returns the index position where the specified Unicode character last appeared in the current string object, starting at 0. 24public int LastIndexOf (string value)
Returns the index position where the specified string last appeared in the current string object, starting at 0. 25public string Remove (int startIndex)
Removes all characters from the current instance, starting at the specified position until the last position, and returns a string. 26public string Remove (int startIndex, int count)
Removes the specified number of characters from the specified position of the current string and returns the string. 27public string Replace (char oldChar, char newChar)
Replaces all specified Unicode characters in the current string object with another specified Unicode character and returns a new string. 28public string Replace (string oldValue, string newValue)
Replaces all specified strings in the current string object with another specified string and returns the new string. 29public string [] Split (params char [] separator)
Returns an array of strings containing substrings in the current string object, separated by elements from the specified array of Unicode characters. 30public string [] Split (char [] separator, int count)
Returns an array of strings containing substrings in the current string object, separated by elements from the specified array of Unicode characters. The int parameter specifies the maximum number of substrings to return. 31public bool StartsWith (string value)
Determines whether the beginning of the string instance matches the specified string. 32public char [] ToCharArray ()
Returns an array of Unicode characters with all the characters in the current string object. 33public char [] ToCharArray (int startIndex, int length)
Returns an array of Unicode characters with all the characters in the current string object, starting at the specified index and ending at the specified length. 34public string ToLower ()
Converts the string to lowercase and returns. 35public string ToUpper ()
Converts the string to uppercase and returns. 36public string Trim ()
Removes all leading and trailing white space characters from the current String object.
The list of methods above is not exhaustive. Visit the MSDN library to see the complete list of methods and the String class constructor.
These are all the contents of the article "what are the properties and methods of the String class in C#". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.