Hi,
I am not sure why the method doesn't change the first letter of each word to Upper Case. Hope some one can help me. (So sorry the title should be this)
namespace ToUpperCaseOnFirstLetterOfWords
{
class Program
{
static void Main(string[] args)
{
string a = "institute of web technologies science";
ConvertToUpperCase(ref a);
}
public static String UppercaseFirstEach(string x) {
char[] s = x.ToLower().ToCharArray();
for (int i = 0; i < x.Count(); i++) // here a.Length can be a.Count(); both will achieve the same result
{
s = i == 0 || s[i - 1] == ' ' ? char.ToUpper(s) : s;
}
Console.WriteLine(x);
return x;
//return Console.WriteLine(x);
}
public static String ConvertToUpperCase(ref String a){
return UppercaseFirstEach(a);
}
}
}
I am not sure why the method doesn't change the first letter of each word to Upper Case. Hope some one can help me. (So sorry the title should be this)
namespace ToUpperCaseOnFirstLetterOfWords
{
class Program
{
static void Main(string[] args)
{
string a = "institute of web technologies science";
ConvertToUpperCase(ref a);
}
public static String UppercaseFirstEach(string x) {
char[] s = x.ToLower().ToCharArray();
for (int i = 0; i < x.Count(); i++) // here a.Length can be a.Count(); both will achieve the same result
{
s = i == 0 || s[i - 1] == ' ' ? char.ToUpper(s) : s;
}
Console.WriteLine(x);
return x;
//return Console.WriteLine(x);
}
public static String ConvertToUpperCase(ref String a){
return UppercaseFirstEach(a);
}
}
}
Last edited: