Generics

Advantage of using generics

  •  reduced run time errors
  • improved performance

Generic class constraints

  • interface
  • Base class
  • Constructor
  • Reference or value type

Generic types and methods are not suitable in all circumstances:

  • The entry point method cannot be a member of an generic type.
  • Unmanaged types cannot be generic.
  • Constructors cannot be generic.
  • Operator member functions cannot be generic methods.
  • Properties cannot be generic.
  • Indexers cannot be generic.
  • Attributes cannot be generic

Generic types include classes, structures, and interfaces

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: