How to get 3 integers value in a single array in c#
I have 3 intergers a,b,c and have values for them as 2,4,5 respectively.. how to store the 3 numbers in a array int[] stats = new int[3];
in c#
and I have 开发者_高级运维to add that value to a string and the output should be like
string val =[2,4,5];
Do you just mean:
int[] stats = { a, b, c };
? Alternatively, as per comments:
var stats = new[] { a, b, c };
or
var stats = new int[] { a, b, c };
int[] stats = {2,4,5};
or
int[] stats = new int[3];
stats[0] = a;
stats[1] = b;
stats[2] = c;
Or do you mean:
int[] stats = new int[3];
stats[0] = a;
stats[1] = b;
stats[2] = c;
?
you can also store as follows
stats[0] = a;
stats[1] = b;
stats[2] = c;
精彩评论