Why can't System.Array be a type constraint?

后端 未结 2 752
忘掉有多难
忘掉有多难 2021-01-17 12:53

I\'m working on a small project with a few different types of arrays (e.g. double[], float[], int[]. For verification / testing / sani

2条回答
  •  借酒劲吻你
    2021-01-17 13:45

    The appropriate syntax to do what you want is this:

    void Print(T[] array)
    {
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write(array[i]);
        }
    }
    

提交回复
热议问题