I'm in the immediate window in Visual Studio. There's a variable p
. How can I deduce the type of the variable p
?
I tried p.GetType()
but that returns the type of object p
. In my case, this is a very specific type (eg. sometimes ChessPlayer
, sometimes TennisPlayer
). I'd like to know the type of the variable, ie. the type that determines what methods are available on the variable p
.
Edit: I think this is a reasonable thing to want to do. I am trying to inspect the variable p
but I don't know it is! Normally in Visual Studio I just hover the mouse on the variable and it tells me its type, or I type .
and the autocomplete lists its methods. However none of that works in the immediate window, all I have is this variable p
I don't know what it is or what I can do with it :(
p.GetType().GetMethods()
?p.GetType().GetInterfaces()
? – Daffyp
, you can see the declaration ofp
in the code and thus see what its "variable" type is. – HaletteBoardGamePlayer p = new ChessPlayer();
, what you want is a way to know thatp
was declared as aBoardGamePlayer
? – Gelinas