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 Wide Comments You can add task lists and comments to your solution. To view the task list for your solution select view menu and click on TaskList option. Ctrl + W, T you will see the following window
You can add the task list items to window by writing the following snippet in the code file.
1 commentSingleton Design Pattern in C#
Best known Creational Design Pattern is Singleton. We can implement this pattern in different ways. I am explaining some of the ways where we can implement in C#.
We will have the following concepts in implementing the Singleton pattern
- We declare a private constructor which prevents other classes to create an instantiation of the singleton class. It also prevents the sub classing.
- We declare a class as sealed so that it can not be instantiated.
- We declare a static variable for holding the reference of a singleton class.
- We declare a public property to return the singleton instance.
- We declare a method for returning the message from the singleton class.
The problem with the above code is it is not a thread –safe code. For example if two threads evaluates the if condition in the above code and both returns the true.
We will rewrite the code for thread safety
The above implementation is thread safe but having the performance issue.
Every time the lock is acquired whenever you request the object.
We can write the above code with out implementing the locks as follows
The static constructor in C# only be called whenever you create a instance for the class.
No commentsC# 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 files in the code.
- Writing & Modifying Code Developers may require to modify the existing code like refractoring which involves make the code readable and fix bugs etc
- Debugging & Testing Understanding the using of debugger tools and writing unit test cases.
Visual studio provides the tools for all the activities mentioned above to make the developer efficient and productive. This post speaks about using the tools available in VS 2008 sp1. It also discusses about the tool coderush express which Microsoft partnering and allows the developers to download and use freely.
1. One of the short cut for goto definition is F12
For example you have an identifier and you want to know where it is declared just press F12. If the identifier is not your project then it shows the metadata of the identifier. eg we are viewing string class
1 commentC# ?? 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 of the method to i if return value is not null other wise it assigns default value
It can be used with reference type as follows
No commentsstring s = GetStringValue(); // ?? also works with reference types. // Display contents of s, unless s is null, // in which case display "Unspecified". Console.WriteLine(s ?? "Unspecified");
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: using alias = CompanyName.ProjectName;
When you use using as Statement it defines the scope and allows the programmer to release the resources used by the object in the defined scope.
The object mentioned in the using statement must implement IDisposable interface. A using statement is can be exited when the end of the using statement is reached.
example :
Font font2 = new Font("Arial", 10.0f);
using (font2)
{
// use font2
}
Multiple objects can be used in with a using statement, but they must
be declared inside the using statement.
example:
using (ResourceType r1 = e1, r2 = e2, …, rN = eN) statement
it is equivalent to the following code
No commentsusing (ResourceType r1 = e1)
using (ResourceType r2 = e2)…
using (ResourceType rN = eN)
statement
New .NET Logo
Microsoft officially announced new logo for Visual studio suite at PDC 2008.
The logo is on light background and dark background.
Why this logo?
It stands for consistency, robustness and greater user experiences. It is reflected in newer brands such as silver light, surface and more. The letter ‘N’ in the logo will become shorthand for the .NET brand name.
No commentsThe Future of C#
Introduction
This post speaks about the future of C# which presented by Anders Hejlsberg chief architect of C# at PDC 2008. The coming version C#4.0 is much concerned on introducing Functional and Dynamic programming language concepts into the C#. It also speaks about C#4.0 features.
The factors that shape the C#4 are
- Declarative programming
- Dynamic programming
- Concurrence programming
Microsoft Health COMMON USER INTERFACE
Introduction
The Microsoft Health Common User Interface (CUI) provides a toolkit with controls which addresses wide range of patient safety concerns for Health Care Organizations all over the world. This tool kit allows the developers to build a new generation of Health Care Applications.
With Microsoft CUI you can
- Quickly and easily develop a Health Care Application
- Design guidance for developing the applications
- Develop applications in Visual Studio Environment
Microsoft developing all these controls using Windows Presentation Foundation and Silver light 2.0 technology.
Microsoft Demonstrated the Features of this controls by developing a patient journey application in NHS 2008 summit.
The following are some of the screen shots of the Application
- Dynamic Search and Results slider
Overview on SharePoint 2007 Features
Introduction
This post explains the SharePoint 2007 features which helps the end users to understand the benefits of MOSS.
Document Library One of the most used features of SharePoint is the document library. It allows the users to manage documents by uploading them to libraries and manage rows and columns of information which is similar to spreadsheet.
Lists another interesting feature in SharePoint 2007(MOSS) which composed of rows and columns much like spreadsheet. Different types of lists in SharePoint are Announcements, Contacts, Discussion Board, Links, Calendar, Tasks, Project Tasks, Survey and Custom Lists.
1 comment