I hope I missed this in the docs. Is there a way to declare a type synonym in C#?
Share
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.
You can use the using statement to create an alias for a type.
For example, the following will create an alias for
System.Int32calledMyIntAlternatively, you can use inheritance to help in some cases. For example
Create a type
Peoplewhich is aList<Person>Not quite an alias, but it does simplify things, especially for more complex types like this
And now you can use the type
SomeStructurerather than that fun generic declaration.For the example you have in your comments, for a
Tupleyou could do something like the following.