If I have the following code:
MyType<int> anInstance = new MyType<int>();
Type type = anInstance.GetType();
How can I find out which type parameter(s) "anInstance" was instantiated with, by looking at the type variable ? Is it possible ?
...
I basically have something like this:
void Foo(Type ty)
{
var result = serializer.Deserialize<ty>(inputContent);
}
Foo(typeof(Person));
The Deserialize<ty> doesn't work because it expects Deserialize<Person> instead. How do I work around this?
I'd also like to understand how generics work and why it won't accept ty which is type...
I'm attempting to create various extension method for a generic type bound to specific generic type parameters in F#, but the language does not seem to be allowing me:
What I want to do is something like the following:
type IEnumerable<int> with
member this.foo =
this.ToString()
Yet it gives me the compiler error (underli...
I have a Class that is defined as
Public MustInherit Class Entity(Of T As Entity(Of T))
And various classes derived from it. I would like to have another class accept all of the derived objects as a property, but I cannot seeem to find a workable syntax. If it were a parameter of a sub, I could say
Public Sub Foo(T As Entity(Of T))...