Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void array_type<type>(type idx,type id)
- where type : class,ICollection
- {
- Console.WriteLine(idx[0]);//idx[0];と書きたい。
- //foreach(var x in idx)
- //{
- // Console.WriteLine(x);
- //}
- //for(int i=0; i< idx.Count; i++)
- //{
- //}
- }
- static void Main(string[] args)
- {
- //dtest a = () => { Console.WriteLine("delegate"); };
- //int[] str = new int[] {1,2,3,4,5,6,7,8,9,10};
- string[] str = new string[3] { "aaa", "bb", "ccc" };
- string[] str2 = new string[3] { "aaavvvvvvvvvvv", "bb", "ccc" };
- array_type<string[]>(str,str2);
- static void ArrayTypeA<T>(T idx)
- where T : IList
- {
- for (int i = 0; i < idx.Count; ++i)
- {
- Debug.WriteLine($"A. idx[{i}] = " + idx[i]);
- }
- }
- static void ArrayTypeB<T>(IList<T> idx)
- where T : IEquatable<T>, IComparable<T>
- {
- for (int i = 0; i < idx.Count; ++i)
- {
- Debug.WriteLine($"B: idx[{i}] = " + idx[i]);
- }
- Debug.WriteLine("idx[0] equals idx[1]: " + idx[0].Equals(idx[1]));
- Debug.WriteLine("idx[0] compareTo idx[1]:" + idx[0].CompareTo(idx[1]));
- }
- public void Test()
- {
- Debug.WriteLine("List<string>");
- var list = new List<string>() { "A1", "A2" };
- ArrayTypeA(list);
- ArrayTypeB(list);
- Debug.WriteLine("string[]");
- var array = new string[] { "BC", "BC" };
- ArrayTypeA(array);
- ArrayTypeB(array);
- }
Add Comment
Please, Sign In to add comment