Q:

Write a C# program to find the length of a string without using library function

0

Write a C# program to find the length of a string without using library function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
public class StringExercise
{
    public static void Main()
    {
        string str; 
        int length = 0;
 
        Console.Write("Input the string : ");
        str = Console.ReadLine();
 
        foreach (char chr in str)
        {
            length += 1;
 
        }
        Console.Write("Length of the string is : {0}\n\n",length);
 
        Console.ReadLine();
    }
}

Result:

Input the string : TechStudy

Length of the string is : 9

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a C# program to count a total number of alph... >>
<< Write a C# program to Separate the individual char...