Question: how can i make a collection that can store a data type (say string, datetime, decimal, etc..)? and that use this collection to perform comparison as such:

```
if (pi.PropertyType.IsIn ([how can check against the collection of type) //where pi is a property info]))
{

}

```

any suggestions?

Answer: 
```
List<Type> types = new List<Type> {typeof(string), typeof(int)};
if (types.Contains(pi.PropertyType))
{
  //do stuff
}

```
Hopefully I understand your question correctly. First a more precise definition of *collection type* is required. Here is what I will use:

* Collections are generic
* Collections are implementing one of the standard collection interfaces like `IList<T>`, `ICollection<T>` or `IEnumerable<T>`. In this example a collection type is a type deriving from `IEnumerable<T>`.

To discover if a type is a collection you have to get the interfaces it implements using `GetInterfaces()`, only look at generic interfaces using `IsGenericType` and then get the generic type (i.e. going from `IList<String>` to `IList<>`) using `GetGenericTypeDefinition()`:

```
var genericCollectionType = typeof(IEnumerable<>);
var isCollection = pi
  .PropertyType
  .GetInterfaces()
  .Where(type => type.IsGenericType)
  .Select(type => type.GetGenericTypeDefinition())
  .Contains(genericCollectionType);
if (isCollection) {
  ...
}

```