Overloading the + operator to add two arrays

后端 未结 5 1738
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 18:53

What\'s wrong with this C# code? I tried to overload the + operator to add two arrays, but got an error message as follows:

One of the parameters of a binary operato

5条回答
  •  无人及你
    2020-12-03 19:49

    You can only add operators to a type that you create yourself. A int[] is a built in type you can't add operators to it.

    You could create your own class that encapsulates an array, and add the operator to it.

提交回复
热议问题