The System String GetLength method is a built-in method in the C# programming language that allows developers to get the length of a string. The method returns an integer that represents the number of characters in the string.
Example 1:
string s = "Hello World!"; int length = s.GetLength();
In this example, we assign a string "Hello World!" to a variable s. We then use the GetLength method to get the length of the string and store it in a variable called length. The value of length in this case would be 12.
Example 2:
string s = ""; int length = s.GetLength();
In this example, we assign an empty string to a variable s. We then use the GetLength method to get the length of the string and store it in a variable called length. The value of length in this case would be 0.
The System String GetLength method is part of the System namespace in the .NET Class Library.
C# (CSharp) System String.GetLength - 30 examples found. These are the top rated real world C# (CSharp) examples of System.String.GetLength extracted from open source projects. You can rate examples to help us improve the quality of examples.