在C#中,有多种方法可以创建一个String数组。以下是其中的几种方法:
string[] array = { "apple", "banana", "orange" };
string[] array = new string[3];
array[0] = "apple";
array[1] = "banana";
array[2] = "orange";
string[] array = Array.CreateInstance(typeof(string), 3) as string[];
array[0] = "apple";
array[1] = "banana";
array[2] = "orange";
string str = "apple,banana,orange";
string[] array = str.Split(',');
string[] fruits = { "apple", "banana", "orange" };
string[] array = (from fruit in fruits
where fruit.Length > 5
select fruit).ToArray();
这些都是创建String数组的常用方法,可以根据具体的需求选择合适的方法。