They are treated as generic definitions, just like generic interfaces and classes are If this number is actually meaningful, then you'd be passing around bad data in cases where that field was null However, you cannot use generic definitions in method signatures, only parameterized generic types
Generics - The Life Raft Group
Quite simply you cannot do what you are trying to achieve with a delegate alone.
A great example of when this would be useful is generic serialization with wildly varying types
If the object being passed in is a string, why do the extra work? What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime What keeps us from comparing the values of generic types which are known to be icomparable Doesn't it somehow defeat the entire purpose of generic constraints?
I have a generics class, foo<t> In a method of foo, i want to get the class instance of type t, but i just can't call t.class What is the preferred way to get around it using t.class? Because under the hood, the compiler will go away and create a new type (sometimes called a closed generic type) for each different usage of the open generic type
I am trying to combine a bunch of similar methods into a generic method
I have several methods that return the value of a querystring, or null if that querystring does not exist or is not in the Using lookupdictionary = system.collections.generic.dictionary<string, int> Now i want to accomplish the same with a generic type, while preserving it as a generic type But that doesn't compile, so is there any way to achieve creating this alias while leaving the type as generic?
If you would want to return a value which is not type casteable to the generic type you pass, you might have to alter the code or make sure you pass a type that is casteable for the return value of method. I think the problem with this is that if you're using this generic method to say, convert a database object from dbnull to int and it returns default (t) where t is an int, it'll return 0