In yesterday’s post We learn about Delegates and how we can use delegates in C#. In today’s blog post we are going to learn about Multicast delegates.
Friday, April 13, 2012
Thursday, April 12, 2012
Delegates in c#
I have used delegates in my programming since C# 2.0. But I have seen there are lots of confusion going on with delegates so I have decided to blog about it. In this blog I will explain about delegate basics and use of delegates in C#.
What is delegate?
We can say a delegate is a type safe function pointer which holds methods reference in object. As per MSDN it's a type that references to a method. So you can assign more than one methods to delegates with same parameter and same return type.Wednesday, April 11, 2012
Dynamically creating meta tags in asp.net mvc
As we all know that Meta tag has very important roles in Search engine optimization and if we want to have out site listed with good ranking on search engines then we have to put meta tags. Before some time I have blogged about dynamically creating meta tags in asp.net 2.0/3.5 sites, in this blog post I am going to explain how we can create a meta tag dynamically very easily.
To have meta tag dynamically we have to create a meta tag on server-side. So I have created a method like following.
To have meta tag dynamically we have to create a meta tag on server-side. So I have created a method like following.
Monday, April 9, 2012
Creating dynamic breadcrumb in asp.net mvc with mvcsitemap provider
I have done lots breadcrumb kind of things in normal asp.net web forms I was looking for same for asp.net mvc. After searching on internet I have found one great nuget package for mvpsite map provider which can be easily implemented via site map provider. So let’s check how its works. I have create a new MVC 3 web application called breadcrumb and now I am adding a reference of site map provider via nuget package like following.
Saturday, April 7, 2012
Execute TSQL statement with ExecuteStoreQuery in entity framework 4.0
I was playing with entity framework in recent days and I was searching something that how we can execute TSQL statement in entity framework. And I have found one great way to do that with entity framework ‘ExecuteStoreQuery’ method. It’s executes a TSQL statement against data source given enity framework context and returns strongly typed result.
You can find more information about ExcuteStoreQuery from following link.
http://msdn.microsoft.com/en-us/library/dd487208.aspx
You can find more information about ExcuteStoreQuery from following link.
http://msdn.microsoft.com/en-us/library/dd487208.aspx
Wednesday, April 4, 2012
Ternary operator in VB.NET
We all know about Ternary operator in C#.NET. I am a big fan of ternary operator and I like to use it instead of using IF..Else. Those who don’t know about ternary operator please go through below link.
http://msdn.microsoft.com/en-us/library/ty67wk28(v=vs.80).aspx
Here you can see ternary operator returns one of the two values based on the condition. See following example.
http://msdn.microsoft.com/en-us/library/ty67wk28(v=vs.80).aspx
Here you can see ternary operator returns one of the two values based on the condition. See following example.
How to pad number with leading zero with C#
Recently I was working with a project where I was in need to format a number in such a way which can apply leading zero for particular format. So after doing such R and D I have found a great way to apply this leading zero format.
I was having need that I need to pad number in 5 digit format. So following is a table in which format I need my leading zero format.
1-> 00001
20->00020
300->00300
4000->04000
50000->5000
So in the above example you can see that 1 will become 00001 and 20 will become 00200 format so on. So to display an integer value in decimal format I have applied interger.Tostring(String) method where I have passed “Dn” as the value of the format parameter, where n represents the minimum length of the string. So if we pass 5 it will have padding up to 5 digits.
I was having need that I need to pad number in 5 digit format. So following is a table in which format I need my leading zero format.
1-> 00001
20->00020
300->00300
4000->04000
50000->5000
So in the above example you can see that 1 will become 00001 and 20 will become 00200 format so on. So to display an integer value in decimal format I have applied interger.Tostring(String) method where I have passed “Dn” as the value of the format parameter, where n represents the minimum length of the string. So if we pass 5 it will have padding up to 5 digits.