Brett Romero wrote:
if I have a public static property such as:
//Class1
public class Class1
{
public static Dictionary<string, string> Prop1{...}
public static Dictionary<string, string> Prop2{...}
}
//SomeClass
public class SomeClass
{
public SomeClass ( CustomDictionary<string, string> pdict )
{//get name of pdict here}
}
// usage
SomeClass myProp1 = new SomeClass( Class1.Prop1 );
How can I get the name of pdict in SomeClass()? Meaning, I want a
string containing "Prop1".
You can't unless you provide a mechanism for them to specifically tell you.
You are getting a reference to an object of type
CustomDictionary<string,string>. You have no way of know that the object
was originally created in the static get_Prop1. What if get_Prop1 had
delegated the creation of its type to some different method? What would you
want to get?
BTW, your code seems upside down. I would expect a CustomDictionary to
derive from Dictionary. If that is the case, a constructor expecting a
CustomDictionary will not be able to accept an object of type Dictionary.
--
Tom Porterfield