Tuesday, 11 December 2012

Highlight color for matched word in visual studio


  1. (tools) (options) under (environment) (fonts and colors)
  2. show settings for (text editor)
  3. under (display options) 
  4. Highlight Reference is the one you want
  5. Change it, maybe restart vs 2010 for good luck.

Monday, 10 December 2012

When to use Partial Class?


Fundamentals of partial classes

A partial class allows a single class to be divided into two separate physical files. During compile time, these files get compiled into a single class. For instance, you can see in the below figure we have the customer class divided into two different files “customer1.cs” and “customer2.cs”.
During compilation, these files get compiled into a single class internally. So when you create an object of theCustomer class, you will be able to see methods lying in both the physical files. For instance, you can see the Addmethod belongs to customer1.cs and the Delete method belongs to customer2.cs, but when the Customer object is created, we can see both the Add and Delete methods.

Fundamentals of partial methods

There is one more important concept in partial classes called partial methods. Partial methods helps us to define a method in one physical file and we can implement that method in another physical file, as shown in the below figure.
In the figure, you can see we have defined the Validate method in Customer1.cs and this Validate method is implemented in Customer2.cs. Please note the partial keywords attached to both of these methods.
l