Hi there,
Quote:
When you want to overload le + operator between type AA and BB, you must do it in the class AA or BB and not in a class named Program (like you did).
Unfortunatly, you cannot write code in the Array class.
What you can do is to
create your own class that implements IList
and put the + operator on that class.
I found this on the net and it's true. I know you want to basically overload the operator for convenience, but you cannot do that, so you have to write a helper method. So if you are using .Net 3.5 or higher, here is my solution to you.
public static byte[] Append(byte[] baseData, byte[] newData)
{
return baseData.Concat(newData).ToArray();
}
If you are using an older .Net framework,
public static byte[] Append(byte[] baseData, byte[] newData)
{
byte[] result = new byte[baseData.Length + newData.Length];
baseData.CopyTo(result, 0);
newData.CopyTo(result, baseData.Length);
return result;
}
Hope this helps, regards