can we find the length of string or array of character in c#
can we find the length of string or array of character in c# without using Length property ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upendra Pratap ShahiPosted Jul 6, 2015, 5:14 AM
Govinda Rajulu YemineniPosted Jul 7, 2015, 12:56 AM
Upendra Pratap ShahiPosted Jul 7, 2015, 12:51 AM
Manoj BhoirPosted Jul 6, 2015, 5:34 AM
MessageBox.Show((array.GetUpperBound(0) + 1).ToString());
Lalit RaghavPosted Jul 6, 2015, 2:07 AM
char[] chararr = str.ToCharArray();
Console.WriteLine("String length= " + chararr.Count());
Rajeesh MenothPosted Jul 6, 2015, 1:40 AM
Rahul PrajapatPosted Jul 5, 2015, 10:31 PM
int count = 0;
foreach (char c in str)
{
count++;
}
Console.WriteLine(count);
Console.ReadKey();
Pankaj Kumar ChoudharyPosted Jul 5, 2015, 8:04 PM
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a string to find its lenght");
string ch = Console.ReadLine();
Program p = new Program();
int answer = p.run(ch);
Console.WriteLine(answer);
Console.ReadKey();
}
public int run(string ch)
{
int count = 0;
foreach (char c in ch)
{
count++;
}
return count;
}
}
Neeraj KumarPosted Jul 5, 2015, 1:58 PM