In C#, is there any difference between using System.Object in code rather than just object, or System.String rather than string and so on? Or is it just a matter of style?
Is there a reason why one form is preferrable to the other?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
stringis an alias forglobal::System.String. It’s simply syntactic sugar. The two are exactly interchangable in almost all cases, and there’ll be no difference in the compiled code.Personally I use the aliases for variable names etc, but I use the CLR type names for names in APIs, for example:
(Note that the return type isn’t really a name – it’s encoded as a type in the metadata, so there’s no confusion there.)
The only places I know of where one can be used and the other can’t (that I’m aware of) are:
nameofprohibits the use of aliases