C#陣列 動態新增元素
阿新 • • 發佈:2018-11-11
string[] a = new string[] { "1", "2", "3" };
給a追加一個 "4"
1 2 3 4 |
string[] a = new
string[] {
"1"
,
"2"
,
"3"
};
List b = a.ToList();
b.Add(
"4"
);
a = b.ToArray();
|
有兩個個數組
byte[] s1 = {1,2,3}
byte[] s2 = {5,6}
要把s2放入s1中
1 2 3 |
byte[] byteOne =
new byte[] { 12, 21, };
byte[] byteTwo =
new
byte[] { 10, 11, 12};
byte[] q = byteOne.Concat(byteTwo).Where(a=>(int)a>0).ToArray();
|