Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

C Sharp string.Length: Difference between revisions

From Coderwiki
new: info, example
 
add example/output section
 
Line 8: Line 8:
int length = name.Length;
int length = name.Length;
Console.WriteLine(name);
Console.WriteLine(name);
</syntaxhighlight>
</syntaxhighlight>Output:
3

Latest revision as of 11:15, 15 August 2025

In C Sharp, any string has the Length property.

You can access it by calling .Length on any string object.

string name = "Bob";
int length = name.Length;
Console.WriteLine(name);

Output:

3
Contents