using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
long a = countstring("This is \n mboxtuts\n Website");
Console.WriteLine("Number of lines in the string is: {0}",a);
Console.ReadLine();
}
static long countstring(string str)
{
long count = 1;
int start = 0;
while ((start = str.IndexOf('\n', start)) != -1)
{
count++;
start++;
}
return count;
}
}
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
long a = countstring("This is \n mboxtuts\n Website");
Console.WriteLine("Number of lines in the string is: {0}",a);
Console.ReadLine();
}
static long countstring(string str)
{
long count = 1;
int start = 0;
while ((start = str.IndexOf('\n', start)) != -1)
{
count++;
start++;
}
return count;
}
}
0 comments:
Post a Comment