开发者

How to get 3 integers value in a single array in c#

开发者 https://www.devze.com 2023-04-02 13:38 出处:网络
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#

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号