How can I use Array.Sort(someArray)
in Mono with the Monodevelop !? I’m using Mono 4.2.2 and Monodevelop 5.10.
Did I has to import some namespace? Which one?
Is there another method to use?
I’ve been trying that and don’t works:
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); }
Advertisement
Answer
Array
is in the System
namespace and is included within mscorlib
(Mono/.Net 2/4/4.5+).
Using:
using System;
Cut/Paste example:
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); } } } }
Output:
Colors: Blue Green Orange Purple Red Press any key to continue...