Here is how I would write a function to make an acronym in Java style:
string makeAcronym(string str)
{
string result = "";
for (int i = 0; i < str.Length; i++)
{
if (i == 0 && str[i].ToString() != " ")
{
result += str[i];
continue;
}
if (str[i - 1].ToString() == " " && str[i].ToString() != " ")
{
result += str[i];
}
}
return result;
}
Is there a more elegant way I can do it with LINQ, or using some built in C# function?