I have a class that has several constructors like this:
var Value; //Does not work
public MyClass(int val, byte[] data)
{
//Assign Value
}
public MyClass(short val, byte[] data)
{
//Assign Value
}
public MyClass(bool val, byte[]data)
{
//Assign Value
}
//......More down
Is it possible to create a Property called Value of the same type as the parameters passed in the constructors? The reason is that i am passing a byte[] coming from a TCP Stream and i need to know the type so i know what Bitconverter function to call.
The alternative I was thinking was to have the caller pass an enum with the type in the constructor as well
Aucun commentaire:
Enregistrer un commentaire