So let's say that I have string[] { "First", "Second", "Third", "Fourth", "Fifth" };, called "a".
And you want to cross out its meanings. Of course, you can use foreach-loop, which is probably the easiest.
foreach (string i in a)
{
Console.Write(i + ", ");
}
This will lead to the following: First, Second, Third, Fourth, Fifth,
Note that the last index has a comma after it. Now, how would you loop in the same way, leaving the last index without a comma and a space?
Tatu source
share