programming-examples/c-sharp/Strings/C# Sharp to find the length of a string without using library function.cs

18 lines
525 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
using System;
public class Exercise2
{
public static void Main()
{
string str; /* Declares a string of size 100 */
int l= 0;
Console.Write("\n\nFind the length of a string :\n");
Console.Write("---------------------------------\n");
Console.Write("Input the string : ");
str = Console.ReadLine();
foreach(char chr in str)
{
l += 1;
}
Console.Write("Length of the string is : {0}\n\n", l);
}
}