May 17, 2012 at 7:44 AM
Edited May 17, 2012 at 7:49 AM
|
class MyArray<T>{
Dictionary<int, T> _Dic = new Dictionary<int, T>();
public int Properties1 { get; set; }
public string Properties2 { get; set; }
public T this[int i]{
get { return _Dic[i]; }
set { _Dic[i] = value; }
}
}
MyArray<int> obj = new MyArray<int>();
obj.Properties1 = 1234;
obj.Properties2 = "neo";
obj[0] = 10;
obj[1] = 20;
JsonConvert.SerializeObject(obj);
//Serialized received:
{"Properties1":1234,"Properties2":"neo"}
// Expected serialized object:
{ [10,20] , "Properties1":1234,"Properties2":"neo" }
In browser this can be achieved by the following code:
var a = [10,20];
a.property1 = 1234;
a.property2 = "neo";
I havn't come across a single place where this issue is adresses.
Can someone put light into it?
|