uSeRnAmEhAhAhAhAhA uSeRnAmEhAhAhAhAhA - 9 months ago 37
ASP.NET (C#) Question

How do I check type of dynamic datatype at runtime?

In my ASP.NET website, I have a method that returns a value of type

. This method, depending on certain criteria and results, will then either return a Boolean value or SortedList.

There is too much code to paste, but for example:

public dynamic ReturnThis(dynamic value)
value = true;
value = new List<String>().Add(new Person() { Name = "Travis" });

return value;

My problem is, I would like to determine the
of value after calling this method before acting on or reading its data. But I am unsure how to check what type
dynamic value
is. How can I do this?


Just read this on another SO question...hopefully it will do the trick for you:

Type unknown = ((ObjectHandle)tmp).Unwrap().GetType();

Read and upvote this question for more info: get the Type for a object declared dynamic