首先,从文档中可以注意到,是可以用字典这种类型的。
然后我遇到了问题,这里写了个简单的例子来描述一下:
public class MainClass
{
public void Main()
{
AVObject.RegisterSubclass<Test>();
Test a = new Test()
{
A = new Dictionary<object, string>() //这一句会报错,但是上述文档中显示可以如此,报错情况如下:
// A = new Dictionary<string,string>() 但是如果改为string或者int这种 就不会有任何问题
};
a.A.Add(123,"456");
a.SaveAsync();
}
}
[AVClassName("Test")]
public class Test:AVObject
{
[AVFieldName("a")]
public Dictionary<object, string> A
{
get => GetProperty<Dictionary<object, string>>("A");
set => SetProperty(value, "A");
}
}
报错:MissingMethodException: Constructor on type 'LeanCloud.Storage.Internal.FlexibleDictionaryWrapper`2[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' not found.
System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) (at :0)