Skip navigation

I’ve discovered that if an extension method is generic and the generic type is used as the "this" parameter, you do not have to write out the generic discriminator. The compiler is smart enough to infer it for you. For example, the range validation function I shared a few weeks ago can be called like so:

int myInt=5;
myInt.ValidateRange(2,20);

Jeff would be happy.

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: