using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace GenericsExample {
static void Main<R>(string[] args) {
List<int> ListGeneric = new List<int> { 5, 9, 1, 4 };
ArrayList ListNonGeneric = new ArrayList { 5, 9, 1, 4 };
Stopwatch s = Stopwatch.StartNew();
Console.WriteLine($"Generic Sort: {ListGeneric} \n Time taken: {s.Elapsed.TotalMilliseconds}ms");
Stopwatch s2 = Stopwatch.StartNew();
Console.WriteLine($"Non-Generic Sort: {ListNonGeneric} \n Time taken: {s2.Elapsed.TotalMilliseconds}ms");
public class GenericList<T>
public void Add(T input) {
public void Remove(T input) { }
private class ExampleClass { }
GenericList<int> list1 = new GenericList<int>();
GenericList<string> list2 = new GenericList<string>();
GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();
list3.Add(new ExampleClass());