I understand that if I cast it to a named type I can do whatever I want with it, but it’d make for much tidier code if I could keep the anonymity between method calls.
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.
Think of the signature of your method as a contract. Your method says “I promise to return you something that contains the following fields.” If you return an anonymous object from your method, there’s no contract. You’re just saying “There’s some data here, good luck!”
If C# 4 is at all an option, you can just use tuples to return somewhat more arbitrary data.