using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program { static int Count1<T>(T a) where T : IEnumerable<T> { return a.Count(); } static void Main(string[] args) { List<string> mystring = new List<string>() { 'rob','tx' }; int count = Count1<List<string>>(mystring);****** Console.WriteLine(count.ToString()); } } }
What do I have to change in the above indicated line of code to make it work. I am just trying to pass either List or array in order to get the count.
You want this