簡體   English   中英

如何在C#中的單個數組中獲取3個整數值

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

我有3個整數a,b,c,分別具有2、4、5的值。.如何將3個數字存儲在array int[] stats = new int[3]; 在C#中

而且我必須將該值添加到字符串中,並且輸出應該像

字符串val = [2,4,5];

你是說:

int[] stats = { a, b, c };

或者,根據注釋:

var stats = new[] { a, b, c };

要么

var stats = new int[] { a, b, c };
int[] stats = {2,4,5};

要么

int[] stats = new int[3];
stats[0] = a;
stats[1] = b;
stats[2] = c;

還是你的意思是:

int[] stats = new int[3];
stats[0] = a;
stats[1] = b;
stats[2] = c;

您還可以存儲如下

stats[0] = a;
stats[1] = b;
stats[2] = c;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM