The solution:
I will have to send a byte array in which the two first bytes of the array make up the type of the class(For instance a change of location of the player) and another byte that will tell the server how long the class's byte array is.
For instance
0 = ChangeLocationPacket
Visually, it would look lik this:
( [0] [5 bytes long] [2] [3] [4] [5] [6] )
^ this will be the new byte array, every byte in the array splitted with a [ and a ].
You would then read it out by firstly checking out what type of class it is using either and if or a switch statement:
if(array[0] == 0)
type = ChangeLocationPacket.GetType();
Then, you would check out how many bytes in length it is:
int Length = (int)array[1];
You could even use two or three bytes to add them up together, or use some magical formula lieing around here in codeproject.
Next, you would read it out, and in this case, there is only one byte which tells how long it is so the code to read it out would be:
Array.Copy(array, 2, newarray, 0, Length);
And afterwards you could return the object and the type in order to convert it back to the class.