0
How could I do this in c # var John = { name: "John", age: 25 }; var James = { name: "James", age: 21 };
5 Respostas
+ 6
Harold SKRTđ€đ€đ€ , the way of doing this depends on what you want to achieve. can you give us some explanations? thanks!
+ 2
I think, smth like:
Dictionary<string, string> John = new Dictionary<string, string>();
John.Add("name", "John");
John.Add("age", "25");
Dictionary<string, string> James = new Dictionary<string, string>();
James.Add("name", "James");
James.Add("age", "21");
+ 1
Var person = new {name = "jhon",age = 25};
Consola.Write(person.name);
+ 1
It will help you may be:
struct John {
public string name;
public int age;
public John(string name, int age) {
this.name = name;
this.age = age;
}
}
struct James {
public string name;
public int age;
public James(string name, int age) {
this.name = name;
this.age = age;
}
}
//Main
John john = new John("John", 25);
James james = new James("James", 21);