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