Wednesday, February 23, 2011

Adding "Web Reference" instead of "Service Reference" in Visual Studio 2010

Although "Service Reference" is a new preferred way to connect to web service/other service type using Visual Studio 2010 and you may notice that it seems like Add "Web Reference" feature is removed. We still can add "Web Reference" by the following steps:

  1. Right click on the project > Add Service Reference...
  2. Click Advanced... button
  3. New dialog will appear. There you will see "Add Web Reference" button

C# - Short cut for "If the value is null, assign the following value instead"

string errorMessage = obj.Message ?? "N/A";


string errorMessage;
if (obj.Message == null)
   errorMessage = "N/A";
   errorMessage = obj.Message;

How to go back after using "Go to Definition (F12)" in Visual Studio 2010

Very easy. Just use Ctrl + "-".