I need a way of getting the "true-type" of an object or a class (in this case a generic-class).. for now all I get is a RuntimeType.. I have read all over the internet but I just cant find an answer that doesnt just return a RuntimeType..
typeof(TModels) returns RuntimeType
1.9k Views Asked by Inx At
2
There are 2 best solutions below
0
phoog
On
System.RuntimeType is an internal concrete class that implements the abstract System.Type class. See the accepted answer to What's the difference between System.Type and System.RuntimeType in C#? for a good discussion. So, you see, as svick said in his comment, RuntimeType is the true type.
You can't find a way that doesn't return a RuntimeType object, because GetType() always returns a RuntimeType object. You will never be able to get a Type object that isn't an instance of some more-derived class, because Type is abstract.
Related Questions in .NET
- Does compiler optimize operation on const variable and literal const number?
- What is the point of definnig Asp.net Intrinsic Objects In different places and what is the different betwen them?
- Deleting Orphans with Fluent NHibernate
- IOrderedEnumerable to vb.net IOrderedEnumerable Conversion
- What is this namespace ITypeOfObjectsBoundToListBox ? Couldn't find it
- .net rest service with JSON string and consumed with java client
- What is best way to check if any of the property of object is null or empty?
- Telerik's WPF RadColorPicker NoColorText property not working
- Possible consequences of duplicate ProgId for different classes
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Optimizing C++ call from C#
- Make a per-web-application object available to Web API and SignalR controllers
- System.ComponentModel.DataAnnotations.Schema namespace conflict
- LINQ Except/Distinct based on few columns only, to not add duplicates
- Not displaying content by its URL string - absolute urls
Related Questions in GENERICS
- Implementing Iterator for abstractCollection
- C# check if there is an overload method with the specific type
- instantiating a generic class data type known at runtime
- How to tell Java that two wildcard types are the same?
- C++ Templates with multiple constraints
- How are the generic functions and types stored in an rlib?
- Java Generics missunderstanding
- Generic webAPI method based on parameter types of arrays
- C# pass generic type as a generic type parameter?
- Return int in method supposed to return generic class
- StarUML Class Diagram : How to manually add Generics (Template Type T) for a class
- Modeling an XML hierarchy for traversal with MVVM
- How to get the values of generic array in Java?
- Swift: converting between Arrays of 'Protocol' and Arrays of implementing Class
- instantiating a generic referance class with data types known at runtime
Related Questions in REFLECTION
- Serializing TypeInfo / Type across .Net Platforms
- C# check if there is an overload method with the specific type
- instantiating a generic class data type known at runtime
- Instantiate a class which implements a generic interface
- C# Activator.GetInstance instances don't retain state when created as Interfaces
- How to force others to obey a specific layout for a child class?
- How should I be using LambdaMetaFactory in my use case?
- Get full path of a package situated in source folder from junit
- instantiating a generic referance class with data types known at runtime
- How to create a Dynamic IEnumerable
- Swift reflection - How to check if a reflected value is a kind of type
- GetTypeInfo Performance in Windows Store Apps
- What's the difference or relationship between Type and TypeInfo?
- Deserializing Generic Types from a ClassLouder class with GSON
- Need to print function's actual parameter name used while calling
Related Questions in TYPES
- Inheritance in Java, apparent type vs actual type
- Converting 8 byte char array into long
- Derby, Java: Trouble with "CREATE_TYPE" statement
- How to tell Java that two wildcard types are the same?
- F# strange type error message
- Convert String scanner to class type
- How to access a Row Type within an Array Type in DB2 SQL PL
- Python Type Dispatching with variables, is it possible?
- Ocaml unbound type constructor with module
- Cloning a Javascript object with its type
- How to remove error of incompatible variable types in LoadLibrary() function?
- What's the difference or relationship between Type and TypeInfo?
- Scala: generic method using implicit evidence doesn't compile
- Guaranteeing data type size
- Convert String With Comma To Number Using Python Pandas
Related Questions in SYSTEM.TYPE
- GenericArguments[0], 'MvcApplication66.Controllers.HomeController+Info', on 'System.Nullable`1[T]' violates the constraint of type parameter 'T'
- New object from type? Specifically a resx file. I want a different resx at runtime
- Error 'Unable to cast object of type 'System.RuntimeType' to type 'EnvDTE80.DTE2'
- typeof(TModels) returns RuntimeType
- How to "EnforceConstraints" to avoid linq errors?
- System.Type; implicit cast to string
- How to detect the difference between an interface and an abstract class?
- Can you pass an IEnumerable<Type> and retrieve the Type?
- Difference between .NET's System.Type.GenericTypeArguments and System.Type.GetGenericArguments()
- Any way to get the definition of a property from the code itself?
- How to instantiate a list of System.Types from a literal?
- System.Type class and the IsPointer property
- How to use a .NET Type in a cast
- Getting Types of all members of a class
- Calling a COM function with System.Type parameter from VBA
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
propertyinfo.PropertyType.GetGenericArguments() should give you a list of the generic arguments.
It is a list because a class can have more then 1 generic.
More info here :
http://msdn.microsoft.com/en-us/library/ms173128.aspx
and here
http://msdn.microsoft.com/en-us/library/b8ytshk6.aspx