Hello Marc,
Do you mean I need to change to :
fieldInfo = this.GetType().GetField("dictioanry1");
Dictionary<string, string> dicTemp1 = fieldInfo.GetValue(this);
Compiling error :
Cannot implicitly convert type 'object' to
'System.Collections.Generic.Dictionary<string,stri ng>'
I need this because "dictionary1" is a string parameters only. I don't know
which dictionary until runtime.
Thanks
Wilson
"Marc Gravell" wrote:
The fieldInfo only knows about the type, not the instance: assuming that
fieldInfo isn't null (which suggests the field is public - is this really
correct?), then:
field.GetValue(this);
would return the value of the field in the current instance (since you are
using this.GetType() I assume this is what you want).
However, if "this" is correct (i.e. you really do mean the current
instance), then you can just use "dictioanry1" [dic] directly, without any
reflection?
dicTemp1 = dictioanry1;
Marc