I would like to check, which type a parameter of a method has, in order to give the variable I determine inside the method with the wished type:
public static Object getFileContent(String filename, Type returntype)
{
if (returntype.GetType().Equals(string))
{
// do something
}
}
This doesn't work. What could I do, to check if returntype is string or List<string>?
returntype == typeof(string)
No need to call GetType because you already have a type. (GetType would not return a useful answer anyway, it would return typeof(Type)).
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