I apologize for such a basic question, but I'm extremely new to C# and can't seem to confidently answer this question:
Why does something like:
string myStringVariable2 = myStringVariable.ToUpper()
not require me to call the String Class?
But something like:
int myIntVariable2 = Math.Abs(myIntVariable)
does require the Math class call-out.
Is ToUpper an "extension" variable and this is why it's not necessary?
Are all methods that can be called with just a period and the method name attached to your variable considered "extension" variables?
When I look up the ToUpper method in the String class, it looks like it's built like other methods so I don't understand why it's not written the same way when referenced. I was expecting to see the use of "this" as a parameter but don't see it.
Please note: any guidance the terms/phrases/terminology used in this question would be greatly appreciated. Part of not being able to find an answer on my owns comes to my very limited and likely inaccurate C# vocabulary.
Thank you very much
Why does something like:
string myStringVariable2 = myStringVariable.ToUpper()
not require me to call the String Class?
But something like:
int myIntVariable2 = Math.Abs(myIntVariable)
does require the Math class call-out.
Is ToUpper an "extension" variable and this is why it's not necessary?
Are all methods that can be called with just a period and the method name attached to your variable considered "extension" variables?
When I look up the ToUpper method in the String class, it looks like it's built like other methods so I don't understand why it's not written the same way when referenced. I was expecting to see the use of "this" as a parameter but don't see it.
Please note: any guidance the terms/phrases/terminology used in this question would be greatly appreciated. Part of not being able to find an answer on my owns comes to my very limited and likely inaccurate C# vocabulary.
Thank you very much
Last edited: