Introduction
In one of forum, someone asked to Write C#.NET program to find the length of string without using library function. So in this snippet we will see to find the length of string without using any built-in library function or string function.
using System;
namespace DotNetMirror
{
class StringLengthWithOutLibraryFunction
{
static void Main()
{
string normalStr = "DotNetMirror";
int charCount = 0;
foreach (char chr in normalStr)
{
charCount = charCount + 1;
}
Console.WriteLine("string '{0}' length is: {1}",normalStr,charCount);
Console.ReadKey();
}
}
}
Output:
string 'DotNetMirror' length is: 12