You can use this to limit it to value types:
where C: struct
You also mention string. Unfortunately, strings won’t be allowed as they are not value types.
More Related Contents:
- C# generic methods, type parameters in new() constructor constraint
- In C#, why can’t a List object be stored in a List variable
- Why isn’t there generic variance for classes in C# 4.0?
- No generic implementation of OrderedDictionary?
- Making a generic property
- foreach vs someList.ForEach(){}
- Why cannot C# generics derive from one of the generic type parameters like they can in C++ templates? [duplicate]
- How do I implement IEnumerable
- What does “where T : class, new()” mean?
- No type inference with generic extension method
- Passing a single item as IEnumerable
- How do I make the return type of a method generic?
- Static Generic Class as Dictionary
- Get a generic method without using GetMethods
- explicitly cast generic type parameters to any interface
- Anonymous Types – Are there any distingushing characteristics?
- A reusable pattern to convert event into task
- C# Generic Type Inference With Multiple Types
- How do I create a generic class from a string in C#? [duplicate]
- Why generic IList does not inherit non-generic IList
- Declare a generic type instance dynamically [duplicate]
- T must be contravariantly valid
- List readonly with a private set
- Why does a generic type constraint result in a no implicit reference conversion error?
- Why doesn’t C# support implied generic types on class constructors?
- What’s Wrong with an ArrayList?
- Implementing arithmetic in generics?
- The component does not have a resource identified by the uri
- How does a generic constraint prevent boxing of a value type with an implicitly implemented interface?
- How to make correct clone of the List? [duplicate]