Or in other words
What are the main difference in type arguments inference for generic types
between C# and Java?
I am looking for an answer that can be read and understood in a few minutes by a skilled C# developer.
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.
The main difference between Java & C# generics is that Java generics are enforced by the compiler, with the required cast being inserted as appropriate. The bytecode does not make reference to the generic type, this is termed ‘type erasure‘.
Within C# generics is present in the intermediate language, hence there is no erasure. As a result you can use reflection to read generic type parameters.
See this related question:
What are the differences between Generics in C# and Java… and Templates in C++?