CSharp - Write program to calculate the length of a string without using Length property

Requirements

Write program to calculate the length of a string without using Length property

Hint

You can loop through the character in a string and do the counting.

Demo

using System;

public class MainClass{
   public static void Main(String[] argv){
        Console.WriteLine("Enter a string");
        string inputString = Console.ReadLine();
        int len = 0;
        foreach (char c in inputString)
        {/*ww w .j ava  2 s.com*/
         len++;
        }
        Console.WriteLine("Length of the string \"{0}\" is {1}", inputString, len);
   }
}

Result