i need static property, which will be more or less complicated object, which propertis might be array, float, int and string
in flash/as3 i would do it by json:
static Object o = {property:1, property2:{subproperty:“text”, subproperty:[{subP:1, subP:2}]}};
is there way in c# ?
1 Answer
1
you can use constructors in your Object to achieve this
public class MyObject {
string text;
float num;
int num2;
int[] sub;
public MyObject(string text, float num, int num2, int[] subprop) {
this.text = text;
this.num = num;
this.num2 = num2;
this.sub = subprop;
//code goes here
}}
to create the static object, you can now use this constructor
static MyObject obj = new MyObject("blurzdfasdf", 69f, 69, new int[] {6,9});
Do you mean it can contain any properties? Isn't it possible to define a class with all possible properties and fill only part of them when initializing? If it's possible, then you can initialize an instance by deserializing JSON.
– ArkaneX