Deep cloning objects

Whereas one approach is to implement the ICloneable interface (described here, so I won’t regurgitate), here’s a nice deep clone object copier I found on The Code Project a while ago and incorporated it into our code. As mentioned elsewhere, it requires your objects to be serializable. The idea is that it serializes your object and then deserializes it into … Read more

HTML.ActionLink method

I think what you want is this: ASP.NET MVC1 This uses the following method ActionLink signature: ASP.NET MVC2 two arguments have been switched around This uses the following method ActionLink signature: ASP.NET MVC3+ arguments are in the same order as MVC2, however the id value is no longer required: This avoids hard-coding any routing logic … Read more

Convert integer to binary in C#

Your example has an integer expressed as a string. Let’s say your integer was actually an integer, and you want to take the integer and convert it to a binary string. Which returns 1000.

Categories c# Tags

How do you sort a dictionary by value?

Use: Since you’re targeting .NET 2.0 or above, you can simplify this into lambda syntax — it’s equivalent, but shorter. If you’re targeting .NET 2.0 you can only use this syntax if you’re using the compiler from Visual Studio 2008 (or above).