I am trying to change the first letter of a string to capital
I saw other questions on this but even when I apply what they've said I still can't manage the correct result.
public string FirstLetterToUpper(string str) { if (str == null) return null; if (str.Length > 1) return char.ToUpper(str[0]) + str.Substring(1); return str.ToUpper(); } private void button1_Click(object sender, EventArgs e) { label1.Text = "test text"; CapitalizeFirstLetter(label1.Text); } Instead of outputting
Test text it remains
test text Any ideas?
label1.Text = CapitalizeFirstLetter("test text");CapitalizeFirstLettermethod? If that's implemented in this way everything is fine and should work:label1.Text=FirstLetterToUpper(input);