c# - create a list Using combination of two types -
i need create list in each member combination of 2 types , b. possible? example, assuming , b:
class { int a1; string a2; } class b { int b1; string b2; }
i want create:
list<a&b> samplelist;
in way a&b contains following properties:
int a1; string a2; int b1; string b2;
try tuples: https://msdn.microsoft.com/en-us/library/dd268536(v=vs.110).aspx
then can use:
var list = new list<tuple<int, string>>(); list.add(new tuple(2, "some text));
and read values like:
console.writeline(list[0].item1); // writes 2 console.writeline(list[0].item2); // writes "some text"
Comments
Post a Comment