Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Tuesday, November 2, 2010

HMAC MD5 in Flex and .Net

Regarding to my previous post, HMAC is a message authentication code (MAC) and can be used to verify the integrity and authentication of a message. I was trying to consume WCF Rest services from Flex.

Tuesday, September 21, 2010

How to measure the time the method takes to run in C#

.Net framework provides StopWatch class in (System.Diagnostics.StopWatch). we can use this class to measure the time for a method takes to finish executing.

Saturday, August 21, 2010

How to load assembly and its references ignoring version number using Reflection

I want to load an assembly A.BC.dll that has a reference to A.XZ.dll and I dont care about the version number for A.BNM.dll, these two assemblies are located in a /ref folder.

Thursday, June 3, 2010

What is System.Lazy<T>

there is a new class in .Net framework 4.0 Called Lazy<T> that provides lazy initialization. Lazy initialization occurs the first time the Lazy<T>.Value property is accessed or the Lazy<T>.ToString method is called and the return value will be cached, it means the second time you access its value, the expression or function does not get executed.

Friday, April 9, 2010

How to Format Decimal numbers in C# and remove extra zero digits

Sometimes you want to show the decimal numbers and you do not want to show the extra zero digits after decimal point.
for below code, if there are one or two digits to the right of the decimal point, that shows up, but, if there are digits of zero to the right of the decimal point, the number is formatted as a whole number

decimal d = 2.340M;
string result = string.Format("{0:0.##}",d); // result will be 2.34

Cheers!