Csharp/CSharp Tutorial/String/String Length
Версия от 15:31, 26 мая 2010; (обсуждение)
Get string length and output string
using System;
class MainClass {
public static void Main() {
string str1 = "ABCDEabcde1234567890";
Console.WriteLine("str1: " + str1);
Console.WriteLine("Length of str1: " + str1.Length);
}
}
str1: ABCDEabcde1234567890 Length of str1: 20
Using string"s Length Member
class MainClass
{
static void Main()
{
string palindrome;
System.Console.Write("Enter a palindrome: ");
palindrome = System.Console.ReadLine();
System.Console.WriteLine("The palindrome, \"{0}\" is {1} characters.",palindrome, palindrome.Length);
}
}