I have used a string in C# where i am using C# in Visual studio 2008. I wanted to convert it to uppercase.
string lowerString = txtCheck.Text;
string upperString = lowerString.ToUpper();
Normally this is how i should have used, But the thing is i didn't get any error when i used it like this
string upperString = lowerString.ToUpper().Tostring();
Now i am confused that ToUpper() is also a function, then how can i use the second syntax where i again use ToUpper().Tostring(); . I mean It would mean Function1().Function2().
No, you're calling ToString
on the object returned by ToUpper
. This is pointless, but it's not a compilation error. If you did:
lowerString.ToUpper.ToString();
that will indeed give you an error, since you can't call a method (ToString) on a method group.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With