Error!
Success!

By tag: ExtensionMethods

showing:  of
0
kicks

Another C# trick: Fluents, Inheritance and Extension Methods  (Unpublished)

Here’s a scenario which Damien and I encountered recently. We needed a way of specifying Facets for properties on Entities, i.e. things like Nullable, MaxLength, Precision etc. And we needed a class hierarchy because different types of properties have different sets of available facets. The...


Kicked By:
Drop Kicked By:
0
kicks

A Handy Extension Method: Raise Events Safely  (Unpublished)

Raising events is a very common practice. We do that a lot and it’s pretty irritating to check for nullity every time. The simple extension methods I present in this post spare the need to repeat this practice every single time.


Kicked By:
Drop Kicked By:
0
kicks

How and when (not) to use Extension Methods in C# and .NET?  (Unpublished)

Lets first briefly examine Extension Methods, show some basics usages and then we will tackle some more advanced and concrete examples used to provide fluent, natural DateTime operations (similar to Date and Time operations available in Ruby on Rails).


Kicked By:
Drop Kicked By:
0
kicks

Add scripts to head dynamically  (Unpublished)

Many times when i develop a user control i have the need to add some javascript to the header of the page. But the header doesn't have a method where you can add script and RegisterStartupScript inserts the script at the bottom of the page. So i thought let's create an extension method...


Kicked By:
Drop Kicked By:
0
kicks

.NET Utility Libraries Galore  (Unpublished)

Yesterday Karl Seguin announced a new .NET Extension Library. One of the really interesting pieces of the library is a streamlined approach to a simple dictionary imagecache, which is similar to the one described in another interesting looking utility library called ShadeTree. Recently, Ayende Rahei...


Kicked By:
Drop Kicked By:
0
kicks

Vb.Net one better than C#  (Unpublished)

This is the first time I have envied VB over C#. Here's a thing that is useful and you can do in Vb.Net, but not in C#.


Kicked By:
Drop Kicked By:
0
kicks

C#: Enhance Enums using Extension Methods  (Unpublished)

Extension Methods are one of the coolest features that have been added in .NET 3.5. I've heard arguments that there is no reason to use them, and the only reason Microsoft added them is to enable the ability to buid LINQ. Well, I do not entirely agree with that statement; in fact, I have found a coo...


Kicked By:
Drop Kicked By:
0
kicks

Extension Methods  (Unpublished)

It is one of the new feature introduced in C# 3.0 “As the name implies, extension methods extend existing .NET types with new methods.” Here i am going to extend the String type to write an extension method. Example Adding a IsValidEmailAddress method onto an instance of string class:


Kicked By:
Drop Kicked By:
0
kicks

Finally, a Good Reason for an Extension Method  (Unpublished)

I finally understand why extension methods are useful.


Kicked By:
Drop Kicked By:
0
kicks

Extension Methods + Attributes = A Whole New World!  (Unpublished)

A post about combining attributes and extension methods in order to extend current code.


Kicked By:
Drop Kicked By:
0
kicks

Useful Extension Method On String  (Unpublished)

.NET Framework provides String.IsNullOrEmpty() method which return true if the string is null or empty. It does not however take care of a string which only contains spaces. Often while persisting data we do not want to persist just empty strings. In past I have made this check before I let my data ...


Kicked By:
Drop Kicked By:
0
kicks

Extension Methods and Scoping  (Unpublished)

There are a few scoping rules that you must keep in mind when using extensions methods. Problems with scoping and extensions methods are rare, but when you encounter them they are quite vexing.


Kicked By:
Drop Kicked By:
0
kicks

MVC: Creating SSL Links/URLs  (Unpublished)

A couple days ago a reader sent in a question regarding how to use SSL with the MVC framework. Specifically the reader wanted to know the easiest way to make an Ajax call to a HTTPS page from a non HTTPS page. The tricky part here is to do so without hard-coding any URLs, so I whipped up a few exten...


Kicked By:
Drop Kicked By:
0
kicks

LINQ Single and SingleOrDefault  (Unpublished)

This post explains about the Single and SingleOrDefault extension methods of LINQ, possible exceptions which can be thrown, and provides code examples both in C# and VB.NET along with code comments.


Kicked By:
Drop Kicked By:
0
kicks

Extension Methods Roundup: IndicesWhere, TakeEvery, Distinct  (Unpublished)

IndicesWhere: Gets the indices where the predicate is true. TakeEvery: Take items from 'startAt' every at 'hopLength' items. Distinct: Gets distinct items by a comparer delegate and Gets distinct items by comparer and hasher delegates (faster than only comparer).


Kicked By:
Drop Kicked By: