Is there a C# equivalent to python's type() function? -
i learning c#
, have basic background in python
familiar type() function data type of variable can returned via:
type(myvariable)
is there c#
equivalent function?
i asking in context of wanting use such function on c# variable has been created using var
eg:
var mynewvariable = "hello!"
i using explicit data types in general eg:
string mynewstring = "hello!"
but wondering data type variable created using var
defaults , thought similar type()
way check out happening 'under hood` speak.
you can try using gettype() method:
type mytype = myvariable.gettype();
for instance
string typename = "my string".gettype().name; // <- "string"
Comments
Post a Comment