正如@UnholySheep 建议的那样,var
如果您DataType
事先不知道,请尽可能使用。
但是例如,由于您已将数据存储target
在图片中并且它的类型为Dictionary
,因此您可以将其投射
Dictionary<string, object> dict = target as Dictionary<string, object>;
现在您可以访问您的数据 dict
编辑 1:
我假设您可能想知道如何从 a 访问数据Dictionary
,所以这里是一个简短的片段:
Dictionary<int, string> myDictionary = new Dictionary<int, string>();
//here _int_ will be the key, _string_ will be your data
myDictionary.Add(1, "abc"); //1 is key, abc is data
myDictionary.Add(2, "def");
myDictionary.Add(3, "ghk");
string myData = myDictionary[2]; //pass the value to be fetched
//myData = def
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句