Mega Code Archive

 
Categories / C# Book / 03 Collections
 

0368 SortedList

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; class Sample { public static void Main() { var sorted = new SortedList<string, MethodInfo>(); foreach (MethodInfo m in typeof(object).GetMethods()) sorted[m.Name] = m; foreach (string name in sorted.Keys) Console.WriteLine(name); foreach (MethodInfo m in sorted.Values) Console.WriteLine(m.Name + " returns a " + m.ReturnType); } } The output: Equals GetHashCode GetType ReferenceEquals ToString Equals returns a System.Boolean GetHashCode returns a System.Int32 GetType returns a System.Type ReferenceEquals returns a System.Boolean ToString returns a System.String