Is it possible to access an object’s private variables using an extension method?
Is it possible to access an object’s private variables using an extension method?
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.
No. You can do the same in an extension method as in a “normal” static method in some utility class.
So this extension method
is equivalent to some static helper method like this (at least regarding what you can access):
(Of course you could use some reflection in either method to access private members. But I guess that’s not the point of this question.)