About 51 results
Open links in new tab
  1. What's the difference between "general" and "generic"?

    Apr 30, 2014 · Generic is the opposite of specific. Generic and specific refer to the identification of a fact. Specific means a fact that has been specified. If you ask for (specify) a pain reliever, aspirin would …

  2. How can I pass in a func with a generic type parameter?

    Mar 24, 2014 · You can certainly define generic delegates, after all, that's exactly what Func and Action are. They are treated as generic definitions, just like generic interfaces and classes are. However, …

  3. C# Generics and Type Checking - Stack Overflow

    In case you happen to have a generic method that returns a generic value but doesn't have generic parameters, you can use default(T) + (T)(object) cast, together with C# 8 pattern matching/type …

  4. How do you provide a default type for generics? - Stack Overflow

    Jul 8, 2009 · The generic parameter type will be the same for all methods, so I would like it at the class level. I know I could make a generic version and then inherit from it for the int version, but I was just …

  5. How to define generic type limit to primitive types?

    Apr 30, 2009 · I have the following method with generic type: T GetValue<T> (); I would like to limit T to primitive types such as int, string, float but not class type. I know I can define generic for clas...

  6. Creating a generic method in C# - Stack Overflow

    Jan 27, 2010 · 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

  7. c# - How to compare values of generic types? - Stack Overflow

    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?

  8. How do I get the type name of a generic type argument?

    Jan 5, 2017 · 26 This extension method outputs the simple type name for non-generic types, and appends the list of generic arguments for generic types. This works fine for scenarios where you …

  9. Cast to generic type in C# - Stack Overflow

    Jun 28, 2016 · 1 As mentioned, you cannot cast it directly. One possible solution is to have those generic types inherit from a non-generic interface, in which case you can still invoke methods on it …

  10. Check if a class is derived from a generic class - Stack Overflow

    Jan 19, 2009 · The rest cases are one of them is a generic definition, only when d is already a generic definition we have the chance to say a t is a d but not vice versa. It should work with arbitrary classes …