Click here to Skip to main content
15,879,184 members

Comments by VermaManish (Top 8 by date)

VermaManish 8-Feb-12 13:03pm View    
I may not be clear enough in my last question. What I was trying to ask is, whether I can get reference of the type object of the class in which "MyClass" is declared as property?
VermaManish 8-Feb-12 5:28am View    
One more question before I start getting into details; is it possible to get the type of the instance in which my type "MyClass" is declared as property? I want to get this inside the "MyClass" class.

public class MyClass
{
private System.String mDescription;
public System.String Description
{
get
{
var stack1DeclaringType = //???
// stack1DeclaringType is expected to be typeOf(MyDeclaringClassA)
return mDescription;
}
set
{
mDescription = value;
}
}
}
VermaManish 2-May-11 3:17am View    
With pleasure! But it was Nishant's solution (Solution 3) that worked for me.
VermaManish 1-May-11 5:19am View    
This is perfectly valid in some cases. We could even use extension methods that can achieve the same pattern a little more elegantly. But let's agree to your argument that we should have bigger preference for language independent semantics. And so, your approach of using implementation helpers seems quite valid. But Nishant’s solution has one big advantage - we are able to encapsulate the implementation of our interfaces. This advantage of (encapsulated implementation) holds big relevance in case of my solution, even if it is at the cost of using language specific semantics. And after all, if everybody would avoid using language specific semantics, there wouldn’t be a need for second language. But I do really appreciate a good pattern that your solution manifests. Thanks
VermaManish 30-Apr-11 13:31pm View    
I think your solution is par excellent!
I'll have to do few more tests related to serializing the generic EducatedAdult, before I come back.
Thanks!