sorry for the weird title, I am having a hard time explaining it. What I want is to compare the characters in my string like this:
stringa = new string[3];
for (int x = 0; x < stringa.GetLength(0); x++)
{
Console.WriteLine("String" + (x + 1) + ":");
stringa[x] = Console.ReadLine();
}
for(int x = 0;x < stringa.GetLength(0);x++)
{
Console.WriteLine(stringa[x]);
}
What I want is that now that I have stringa[x], I want to compare every character inside that string. Is there any way I can do that without using any temporary variables?
You can get a character within a string by indexing. For instance:
Will write the character ‘T’
In your case, you could put another for loop inside your second one and call
stringa[x][y]to get the y’th character instringa[x], but it’s more efficient to storestringa[x]in a local variable and index that, like so: