c# - Generics problem -


i'm making class can cheat @ minesweeper, , building generics... i'm kinda stuck. want return int how 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 cast return value call changetype

return (t)convert.changetype(memoryreader.readint(adr), typeof(t));  

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -