Recently some of colleagues were discussing about how to create overload methods in web service. We can’t directly create overloaded method web methods for web service. So I thought It would be great idea to write a blog post about it.
Function overloading is one of most known concepts of Object Oriented Programming. It’s a technique to implement polymorphism in code. Like in other programming language in c# you can also create multiple functions with same name and different argument. In function overloading function call will be resolved by ‘Best Match Technique’.
To understand this let’s create a simple web service with two HelloWorld Methods one with parameter and one without parameter both will return a string. Following is a code for that.
Wednesday, January 30, 2013
Tuesday, January 29, 2013
Visual studio 2012 color editor- Make Visual studio 2012 Colorful
This blog will be part of visual studio 2012 features series.
I personally like the Metro UI for Visual Studio 2102 but still some people are not happy with it. They really like Old Visual Studio 2010 layout and they wanted to have same kind of color in visual studio 2012. For those who want to change the color of Visual studio there is a plug in called Visual Studio 2012 Color Theme editor. From which you can set colors for visual studio UI and make your visual studio look colorful. Following is a link for that.
http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05
Once you download that from above location and click on installer it will ask for accepting terms and conditions like following.
I personally like the Metro UI for Visual Studio 2102 but still some people are not happy with it. They really like Old Visual Studio 2010 layout and they wanted to have same kind of color in visual studio 2012. For those who want to change the color of Visual studio there is a plug in called Visual Studio 2012 Color Theme editor. From which you can set colors for visual studio UI and make your visual studio look colorful. Following is a link for that.
http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05
Once you download that from above location and click on installer it will ask for accepting terms and conditions like following.
Sunday, January 27, 2013
C# null-coalescing operator ??
C# language provides many features and null-coalescing operator(??) is one of them. It’s a great operator to check whether object is null and if it is null then it will provide a default value. I have seen most of the people are not using while it’s a great feature. So I decided to write a blog about this.
You can find more information about null-coalescing operator from the below link.
http://msdn.microsoft.com/en-us/library/ms173224.aspx
You can find more information about null-coalescing operator from the below link.
http://msdn.microsoft.com/en-us/library/ms173224.aspx
Tip-Convert array to Comma delimited string
I was needed to convert an string array into the comma delimited string and the old way to do that is too with for loop. But I was sure that there should be some ready made function that will do this very easily.
After doing some research I have found string.Join. With the help of this we can easily an array into the comma delimited string.
String.join have two arguments one is separator and other one is either array or enumerable.
Following is a code for that.
After doing some research I have found string.Join. With the help of this we can easily an array into the comma delimited string.
String.join have two arguments one is separator and other one is either array or enumerable.
Following is a code for that.
namespace ConsoleApplication3 { class Program { static void Main() { string[] name = {"Jalpesh", "Vishal", "Tushar", "Gaurang"}; string commnaDelmietedName = string.Join(",", name); System.Console.WriteLine(commnaDelmietedName); } } }
Friday, January 18, 2013
Linq performance with Count() and Any()
Recently I was using resharper to refactor some of my code and found that it was suggesting to use any() extension method instead of count() method in List<T>. I was really keen about performance and found that resharper was right. There is huge performance difference between any() and count() if you are using count() just to check whether list is empty or not.
In Count() method code will traverse all the list and get total number of objects in list while in Any() will return after examining first element in the sequence. So in list where we have many object it will be significant execution time if we use count().
Difference between Count() and Any():
How to get N row from datatable in C#
Problem:
Possible Solutions to problem:
- With normal for loop
- With lamda expression and linq
1. With normal for loop:
Following is code from where we can get 3 rows of data table.Thursday, January 17, 2013
New Milestone for Dotnetjalps.com-500000 visits for my blog
Today I got great news from sitemeter.com that my blog http://www.dotnetjalps.com completed 500,000 visitors for my blog. This is a new milestone achieved for this blog and I would like to thank all my blog readers for making this blog this much bigger.
On this occasion I would like to thanks all supporters, friends and my family members who have faith in me and believe that I could do something and this all because of them and my blog readers.
Followings are my statistics for my blog.
On this occasion I would like to thanks all supporters, friends and my family members who have faith in me and believe that I could do something and this all because of them and my blog readers.
Followings are my statistics for my blog.
Saturday, January 5, 2013
Search and filters available in visual studio 2012
I have already written lots of post about Visual Studio 2012 features and this post is also going to be part of that series. You can get whole series of post from the following link.
Visual Studio 2012 features
In this post we are going to talk about search and filters provided into the visual studio 2012. There are lots of emphasis there in search and filters in visual studio 2012.You can almost search every thing including errors also. There are different search options are available for that.
Prior to previous edition in visual studio 2012 there was quick launch search given at the top of the visual studio. From here you can search for anything in solutions and even menu’s also. It will provide you a quick launch for that.
Visual Studio 2012 features
In this post we are going to talk about search and filters provided into the visual studio 2012. There are lots of emphasis there in search and filters in visual studio 2012.You can almost search every thing including errors also. There are different search options are available for that.
Quick launch search in visual studio:
Friday, January 4, 2013
Lazy<T> in C# 4.0
Before C# 4.0 there was no on demand initialization by default. So at the time of declaration we need to create a value or object will be null or we have to create on demand initialization via coding.. But with C# 4.0 we now have lazy class. As per MSDN it support lazy initialization so it means if we use lazy class then it will initialize the object at the time of demand.
It is very useful for UI responsiveness and other scenario's. Lazy initialization delays certain initialization and it’s improve the start-up time of a application. In the earlier framework if we need this kind of functionality we have to do it manually via coding but from C# 4.0 onwards it have Lazy<T> class. With the Help of this we can improve the responsiveness of C# application. Following is a simple example.
It is very useful for UI responsiveness and other scenario's. Lazy initialization delays certain initialization and it’s improve the start-up time of a application. In the earlier framework if we need this kind of functionality we have to do it manually via coding but from C# 4.0 onwards it have Lazy<T> class. With the Help of this we can improve the responsiveness of C# application. Following is a simple example.