Find String Length without using Inbuilt Function in C#

  1. namespace ConsoleApplication2 {  
  2.     class Program {  
  3.         static void Main(string[] args) {  
  4.             string ValString;  
  5.             Console.Write("Enter Your String:");  
  6.             ValString = Console.ReadLine();  
  7.             int x = 0;  
  8.             foreach(char c in ValString) {  
  9.                 Console.Write(ValString[x]);  
  10.                 x++;  
  11.             }  
  12.             Console.WriteLine("\nLength Of String:{0}", (x));  
  13.             Console.Read();  
  14.         }  
  15.     }  
  16. }  
Sample Output:

Enter Your String: Welcome To Csharp

Welcome To Csharp

Length Of String:17