TechBubbles Microsoft Technology BLOG

TagC#

C# IDE Tips & Tricks Part 2

This post explains the some more tips on using Visual C# IDE to enhance developer productivity. Solution Configurater  Right click your solution in your IDE then select the ConfigurationManager  you see the following window   where you have the option to select the project for building. We can select the required project in the solution and can you can build the project. Solution...

C# IDE Tips & Tricks Part 1

C# Developers have been spending most their day activities with Visual studio IDE. They may have to understand the following activities to do their job. Understanding Code Developer must be able analyze the relationship between classes and what API it is using for implementing the logic. Navigating Code Developer may or may not know where he want to navigate to the code and keep track of visited...

C# ?? operator

The ?? operator in C# called null-coalescing operator is used to define a default value for a nullable value types and reference types. It returns the left-hand operand if it is not null and returns right-hand operand if it is null. example // ?? operator example . int? x = null; int y = x ?? –1; // Here the value of y will be –1. int i = GetValue() ?? default(int); Assigns the return value...

Using keyword in C#

Introduction Using keyword in C# can be used as directive and as well as statement. When you use using as Directive you will get the following advantages You can use the types in a namespace by declaring with using keyword.         example: using Systetm.Web;   You can define a alias for the nested namespaces        example:...

Calculating the size of the File in C#

Introduction This code snippet explains how to calculate the size of the file and display in a label control. For example I am taking PDF file to find the size. It Displays the size of the file in Bytes, Kilobytes and Megabytes.   //Calculate size of the PDF file        if (PdfFilePath.EndsWith("pdf"))        {...

Lambda Expressions in C# 3.0

Lambda expressions is one of the features introduced in the C# 3.0. Lambda expressions help you to ease the burden of writing verbose Anonymous Methods. I will explain the where to use the Anonymous methods first then we see the example on lambda expressions Anonymous Methods Anonymous Methods is the feature in C# 2.0. The idea behind writing the anonymous methods is to write methods inline to...

Extension Methods Feature in C# 3.0

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: namespace Extensions { class TestProgram {      static  void  Main(string[]...

Object and Collection Initializers Feature in C# 3.0

C# 3.0 introduced the another interesting feature Object and Collection initialization expressions. Object Intialization  Expressions allows you to initialize an object without invoking the constructor and setting its properties. If you take Employee Class as an Example: public class Employee { private int iEmpId; private string strFirstName; private string strLastName; public int ID{ get{...

Automatically Implemented Properties Feature in C# 3.0

Introduction of Automatic Properties in C# 3.0 make property declaration more concise. It saves some of your time in typing a lot of code. Example: class Employee { public string FirstName { get; set; } } Benefit of using Automatic Properties We have been creating properties in so many projects and notice that we are writing so many lines of code just for creating a simple property. Example:...

Test driven development using C#

This post explains how TDD can be implemented in C# using NUNIT. You can read the Introduction TDD to get an idea on TDD. Nunit is a open source framework to for .NET which helps you to automate the unit testing. Nunit can downloaded from the Nunit site. current version is 2.5. Nunit provides two utilities for running the automated tests nunit-gui.exe – GUI tool nunit-console.exe – Command...

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud