Seems like we could just have a normal statically checked assignment. I’m not sure I see the advantage in this case. What am I missing?
Seems like we could just have a normal statically checked assignment. I’m not sure
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.
The issue here is that
foreachwas designed prior to generics, which didn’t exist until .NET 2.0. With .NET 1.1, if you used a collection class, theIEnumeratorinterface’sCurrentproperty always returnsSystem.Object.By having foreach do the cast, you could write:
Instead of having to explicitly write:
Granted, with .NET 2, this is not really an issue anymore.