如何使用Monodevelop在Mono中使用Array.Sort(someArray)
!我使用的是Mono 4.2.2和Monodevelop 5.10。
我是否必须导入一些命名空间?哪一个?
还有其他方法可供使用吗?
我一直在努力尝试并且不起作用:
var Color = new String[5];
Color[0] = "Orange";
Color[1] = "Blue";
Color[2] = "Purple";
Color[3] = "Green";
Color[4] = "Red";
Array.Sort(Color); //Error: The type or namespace name 'Sort' does not exist in namespace 'Array'. Are you missing an assembly reference?
Console.WriteLine ("Colors:");
foreach(string s in Color)
{
Console.WriteLine (s);
}
答案 0 :(得分:0)
Array
位于System
命名空间中,包含在mscorlib
内(Mono / .Net 2/4 / 4.5 +)。
using System;
using System;
namespace ArraySort
{
class MainClass
{
public static void Main(string[] args)
{
var Color = new String[5];
Color[0] = "Orange";
Color[1] = "Blue";
Color[2] = "Purple";
Color[3] = "Green";
Color[4] = "Red";
Array.Sort(Color); //Error: The type or namespace name 'Sort' does not exist in namespace 'Array'. Are you missing an assembly reference?
Console.WriteLine ("Colors:");
foreach(string s in Color)
{
Console.WriteLine (s);
}
}
}
}
Colors:
Blue
Green
Orange
Purple
Red
Press any key to continue...