c#: How do I accept any kind of number into a function as an argument? Currently my AddDataInt32() asks specifically for Int32, but how I can accept any number, byte, ints signed or unsigned, so I can pass it on to BitConverter.GetBytes()? It’s seems silly to write same funct’s for each type 🙁
public void AddDataInt32(Int32 i) { Data = ConcatTwoByteArrays(Data, BitConverter.GetBytes(i)); }
You can just overload the method…
etc. One for each number type. When you make the call to the procedure, it will take any form of number that you’ve coded, with the same procedure name.