About 783,000 results
Open links in new tab
  1. 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. …

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

    So, two questions: Why do we observe this weird behaviour? What keeps us from comparing the values of generic types which are known to be IComparable? Doesn't it somehow defeat the …

  3. Using List<T> in C# (Generics) - Stack Overflow

    Oct 2, 2013 · 18 You need to add the generic type parameter for T to your method: void MyMethod<T>(List<T> list) { The compiler doesn't know what T represents, otherwise.

  4. Can I make a generic optional, defaulting to a certain class?

    Dec 5, 2012 · My question is related to Is there a reasonable approach to &quot;default&quot; type parameters in C# Generics?, but using an inner generic class that approach doesn't work. …

  5. Using Mockito to mock classes with generic parameters

    Is there a clean method of mocking a class with generic parameters? Say I have to mock a class Foo&lt;T&gt; which I need to pass into a method that expects a Foo&lt;Bar&gt;. I can do the …

  6. Generic method multiple (OR) type constraint - Stack Overflow

    May 31, 2012 · Reading this, I learned it was possible to allow a method to accept parameters of multiple types by making it a generic method. In the example, the following code is used with a …

  7. C# generic type constraint for everything nullable

    Apr 11, 2017 · The first suggestion using default is perfect! Now my template with a generic type being returned can return a null for objects and the default value for built-in types.

  8. How to reference generic classes and methods in xml …

    Note that the other answers cover how to reference a generic class, this answer shows you how to reference the type parameter on its own, which happened to be what I was looking to do.

  9. 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 …

  10. exception - Generic catch for python - Stack Overflow

    Jan 14, 2009 · Generic catch for python Asked 16 years, 6 months ago Modified 5 years, 2 months ago Viewed 134k times