You can use Convert.ChangeType
SomeClass obj2 = (SomeClass)Convert.ChangeType(t, typeof(SomeClass));
Although, keep in mind that this will throw an exception if a cast is invalid.
Related Contents:
- How do I use reflection to call a generic method?
- ArrayList vs List in C#
- A generic list of anonymous class
- Passing arguments to C# generic new() of templated type
- Passing a single item as IEnumerable
- Create instance of generic type whose constructor requires a parameter?
- What’s the difference between SortedList and SortedDictionary?
- Pass An Instantiated System.Type as a Type Parameter for a Generic Class
- How do I make the return type of a method generic?
- C# Create New T()
- Select a Dictionary with LINQ
- Func with out parameter
- How to initialize a List to a given size (as opposed to capacity)?
- No generic implementation of OrderedDictionary?
- Convert string to nullable type (int, double, etc…)
- What exactly is an “open generic type” in .NET? [duplicate]
- Does .NET have a way to check if List a contains all items in List b?
- What does denote in C# [duplicate]
- Are static members of a generic class tied to the specific instance?
- Can I use a collection initializer for Dictionary entries?
- How to compare values of generic types?
- What is the syntax for a default constructor for a generic class?
- How to define generic type limit to primitive types?
- C#’s equivalent of Java’s
- Mocking generic methods in Moq without specifying T
- How to make a Generic Type Cast function [duplicate]
- What does “T” mean in C#?
- How do I tell if a type is a “simple” type? i.e. holds a single value
- What is the generic version of a Hashtable?
- IUnityContainer.Resolve throws error claiming it cannot be used with type parameters
- Making a generic property
- How, when and where are generic methods made concrete?
- generic NOT constraint where T : !IEnumerable
- How to call generic method with a given Type object? [duplicate]
- SortedSet vs HashSet
- Convert DataTable to List
- Why does the C# compiler allow an explicit cast between IEnumerable and TAlmostAnything?
- Where are generic methods stored?
- IEnumerable to IReadOnlyCollection
- Why it is not possible to define generic indexers in .NET?
- Generic Type in constructor
- The component does not have a resource identified by the uri
- How do you provide a default type for generics?
- Generic Constraint for Non Nullable types
- Ambiguous call between two C# extension generic methods one where T:class and other where T:struct
- Initializing a Generic.List in C#
- T must be contravariantly valid
- Why cannot C# generics derive from one of the generic type parameters like they can in C++ templates? [duplicate]
- Getting a KeyValuePair directly from a Dictionary
- How do I copy the content of a dictionary to an new dictionary in C#?