Adsence750x90

Wednesday, August 15, 2012

Visual Studio 2012 and .NET Framework 4.5 is Released

Microsoft announced the  availability of Microsoft .NET Framework 4.5 and Visual Studio 2012 today.http://blogs.msdn.com/b/dotnet/archive/2012/08/15/announcing-the-release-of-net-framework-4-5-rtm-product-and-source-code.aspx
You can download Visual Studio 2012 from http://www.microsoft.com/visualstudio/11/en-us 
and take a look on Whats new in Framework 4.5 http://msdn.microsoft.com/library/ms171868(v=vs.110).aspx

What's New in ASP.NET 4.5 and Visual Studio 2012 http://www.asp.net/vnext/overview/whitepapers/whats-new
Learn What's New By Tutorial Visual Studio 2012 http://msdn.microsoft.com/en-US/library/hh420390.aspx#whatsnew_scenario
Reference Source Code Center [RSCC]  http://referencesource.microsoft.com/
Releasing the source code for the .NET Framework 4.5 libraries http://referencesource.microsoft.com/netframework.aspx

Sunday, August 12, 2012

Decimal to fraction convertion c#

I think there is nothing to explain below code. I used this code snippet to calculate the fractional value of a decimal number. Might help someone.
        /// 
        ///  return fraction from decimal value
        /// 
        /// 
        /// string
        /// 
        /*
         * logic:
         * x=5.333
         * 10x=53.33
         * 10x-x=Math.Round(53.33-5.333)
         * 9x=48
         * x=48/9
         * find common factor
         * divide both side by commen factor [ nuerator and denominator]
         * return faction
         * */
 public string DecimalToFraction(decimal decimalvalue)
        {
            decimal decimalTemp = decimalvalue;
            string returnDecimalvalue = string.Empty;
            decimal temp = decimalTemp * 10;
            decimal numerator = System.Decimal.Round(temp - decimalTemp);
            decimal denominator = 10 - 1;

            int comFact = getCommonFactor((int)numerator, (int)denominator);
            returnDecimalvalue = (numerator / comFact).ToString() + "/" + (denominator / comFact).ToString();
            return returnDecimalvalue;
        }


 
function to find the common factor
private int getCommonFactor(int a, int b)
        {
            int count;
            while (b != 0)
            {
                count = a % b;
                a = b;
                b = count;
            }
            return a;
        }
Thanks.