type-constraints
C# 4.0 dynamic: A potential performant solution to numeric generics?
After coming up against this problem myself in trying to implement a generic Vector2<int/float/double> in C#, I\'ve done a bunch of investigation into this problem, also described in this questi[详细]
2023-02-11 06:11 分类:问答Why Do I need to redeclare type constraint in generic subclass
Recently I tried to create a generic subclass by implementing a generic interface. public interface IModule<T> where T : DataBean { ..... }[详细]
2023-02-03 00:03 分类:问答Shorter way to constraint a function
I\'m looking for a shorter way (if there is one) to constraint a function. E.g. let inline sincos (a:\'T) =[详细]
2023-01-30 13:31 分类:问答How do I translate a `where T : U` generic type parameter constraint from C# to F#?
F# is giving me some trouble with its type inference rules. I\'m writing a simple computation builder but can\'t get my generic type variable constraints right.[详细]
2023-01-25 11:52 分类:问答Constrain type parameter of a method to the interfaces implemented by another type
The intention开发者_StackOverflow of the following is to only allow the call IRegistration<Foo>.As<IFoo> if Foo implements IFoo:[详细]
2023-01-23 05:52 分类:问答Is there a technique to differentiate class behavior on generic types?
I\'d like to do something like the following, but because T is essentially just a System.Object this won\'t work.I know T can be constrained by an interface, but that isn\'t an option.[详细]
2023-01-20 07:18 分类:问答Can I dictate that a C# type parameter must only be an interface type?
I would like to implement a generic C# class which looks roughly as follows: abstract class Foobar<T> : AbstractBase, T[详细]
2023-01-19 17:42 分类:问答How to specify a type parameter which does NOT implement a particular interface?
I have developed some extension methods for objects, which I don\'t want to be used/shown in intellisense for objects which implements IEnumerable. Conceptually I want something like as follows[详细]
2023-01-18 20:22 分类:问答Static extension methods supporting member constraints
I need to implement a static extension method supporting member constraints on some basic primitive types like integers, floats, etc. Here\'s my code for signe开发者_StackOverflowd integers:[详细]
2023-01-15 07:07 分类:问答Writing an extension method for type T; how can I add a type constraint for a field of T?
Initial situation: I am working with a proprietary framework (ESRI\'s ArcGIS Engine) which I want to extend with some new functionality. I\'ve chosen to use extension methods in C# for this.[详细]
2023-01-05 19:52 分类:问答