Generation

generate functionSat, 12 Nov 2022

compare two lists of objects by the name of their classes

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _03_CompareByClass { class ChooseByClass { static void Main(string[] args) { List<int> first = new List<int>() { 3, 6, 8, 0, 2, 7, 1, 8, 9, 4 }; List<string> second = new List<string>() { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }; Comparer<List> comparer = new Comparer<List>(); Console.WriteLine(comparer.Compare(first, second)); } } } public class Comparer<T> { public int Compare(T a, T b) { if (a.GetType() == b.GetType()) { return 0; } else

Questions about programming?Chat with your personal AI assistant