I'm making a class so I can cheat at minesweeper, and is currently building up some generics... but I'm kinda stuck. I want to return a int but how do i convert it?
public T ReadMemory<T>(uint adr)
{
if( address != int.MinValue )
if( typeof(T) == typeof(int) )
return Convert.ChangeType(MemoryReader.ReadInt(adr), typeof(T));
else
MessageBox.Show("Unknown read type");
}
You need to cast the return value from the call to ChangeType
return (T)Convert.ChangeType(MemoryReader.ReadInt(adr), typeof(T));
Try casting:
return (T)Convert.ChangeType(MemoryReader.ReadInt(adr), typeof(T));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With