C# Tips and Tricks

Learn some tips and tricks with the C# 3.0 language features along with exploring some productivity gains with the Visual Studio IDE.

As the title indicates, this article will be about C# tips and tricks. I'll cover some of the C# 3.0 language features, explore productivity gains with the Visual Studio 2008 C# IDE, and mention a couple of handy Visual Studio plug-ins that may be of interest. This deviates from the traditional articles I've presented in the past and will hopefully provide some value in its own way.



C# 3.0 Background



C# 3.0 was released as a part of the Microsoft .NET 3.5 Framework. The main purpose was to provide a foundation for Language INtegrated Query (LINQ) to provide unified data access capability. Each enhancement also can be used on its own. Here is a list of the features you'll cover and learn some related tips:




  • Automatically implemented properties

  • Using Keyword

  • Object and collection intitializers

  • Local type inference

  • Extension methods



Automatically Implemented Properties



Automatically implemented properties offer a concise syntax for implementing property accessors that get and set a private field. They create a field backed property without requiring you to actually create a field. The compiler automatically generates it for you at compile time. They can be used only for simple get and set of properties because there is no body and no field. No property body means no breakpoints or validation logic can be used. No field means no default value. Typing "prop [tab][tab]" is the Visual Studio code snippet for producing an automatically implemented property. This can make your code much more concise. A classic example of a field back property might look something like the code below.




private int myProperty = 0;
public int MyProperty
{
get { return this.myProperty; }
set { this.myProperty = value; }
}


Read the Rest of this Article at Developer.com

Regional Articles
- C# Tips and Tricks Alabama
- C# Tips and Tricks Alaska
- C# Tips and Tricks Arizona
- C# Tips and Tricks Arkansas
- C# Tips and Tricks California
- C# Tips and Tricks Colorado
- C# Tips and Tricks Connecticut
- C# Tips and Tricks DC
- C# Tips and Tricks Delaware
- C# Tips and Tricks Florida
- C# Tips and Tricks Georgia
- C# Tips and Tricks Hawaii
- C# Tips and Tricks Idaho
- C# Tips and Tricks Illinois
- C# Tips and Tricks Indiana
- C# Tips and Tricks Iowa
- C# Tips and Tricks Kansas
- C# Tips and Tricks Kentucky
- C# Tips and Tricks Louisiana
- C# Tips and Tricks Maine
- C# Tips and Tricks Maryland
- C# Tips and Tricks Massachusetts
- C# Tips and Tricks Michigan
- C# Tips and Tricks Minnesota
- C# Tips and Tricks Mississippi
- C# Tips and Tricks Missouri
- C# Tips and Tricks Montana
- C# Tips and Tricks Nebraska
- C# Tips and Tricks Nevada
- C# Tips and Tricks New Hampshire
- C# Tips and Tricks New Jersey
- C# Tips and Tricks New Mexico
- C# Tips and Tricks New York
- C# Tips and Tricks North Carolina
- C# Tips and Tricks North Dakota
- C# Tips and Tricks Ohio
- C# Tips and Tricks Oklahoma
- C# Tips and Tricks Oregon
- C# Tips and Tricks Pennsylvania
- C# Tips and Tricks Rhode Island
- C# Tips and Tricks South Carolina
- C# Tips and Tricks South Dakota
- C# Tips and Tricks Tennessee
- C# Tips and Tricks Texas
- C# Tips and Tricks Utah
- C# Tips and Tricks Vermont
- C# Tips and Tricks Virginia
- C# Tips and Tricks Washington
- C# Tips and Tricks West Virginia
- C# Tips and Tricks Wisconsin
- C# Tips and Tricks Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML