Compartilhar via


Generics in the .NET Compact Framework 

The .NET Compact Framework provides core language feature compatibility for C# and Visual Basic in the implementation of generics and generic collections.

The following differences apply between generics in the .NET Compact Framework and in the full .NET Framework:

  • Expansive generic recursion through fields is not supported. For example, the following C# field declaration is not supported:

    class MyData<T> 
    { 
        MyData<MyData<T>> field;
    }
    

    Other kinds of generic recursion are supported, such as the following C# class declarations:

    class C : IComparable<C>
    class C<T> : IComparable<C<T>>
    
  • The .NET Compact Framework does not validate constraints for normal execution in the absence of a verifier. Reflection will still verify the constraints when binding to generic parameters.

  • The number of generic parameters you can use is limited to eight.

  • The .NET Compact Framework provides limited reflection functionality for generic types and methods, sufficient for supporting C# and Visual Basic runtime and class library dependencies.

See Also

Other Resources

Application Development in the .NET Compact Framework