コード例 #1
0
        public double GetAreaConversion(areaUnitEnum from, areaUnitEnum to)
        {
            if (from == areaUnitEnum.SquareCentimeters)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 1; }
                else if (to == areaUnitEnum.SquareFeet) { return 0.001076391; }
                else if (to == areaUnitEnum.SquareInches) { return 0.15500031; }
                else if (to == areaUnitEnum.SquareKilometers) { return 1 * Math.Pow(10, -10); }
                else if (to == areaUnitEnum.SquareMeters) { return 0.0001; }
                else if (to == areaUnitEnum.SquareMiles) { return 3.8610215855 * Math.Pow(10, -11); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 100; }
                else if (to == areaUnitEnum.SquareYards) { return 0.000119599; }
            }
            else if (from == areaUnitEnum.SquareFeet)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 929.0304; }
                else if (to == areaUnitEnum.SquareFeet) { return 1; }
                else if (to == areaUnitEnum.SquareInches) { return 144; }
                else if (to == areaUnitEnum.SquareKilometers) { return 9.290304 * Math.Pow(10, -8); }
                else if (to == areaUnitEnum.SquareMeters) { return 0.09290304; }
                else if (to == areaUnitEnum.SquareMiles) { return 3.5870006428 * Math.Pow(10, -8); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 92903; }
                else if (to == areaUnitEnum.SquareYards) { return 0.1111; }
            }
            else if (from == areaUnitEnum.SquareInches)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 6.4516; }
                else if (to == areaUnitEnum.SquareFeet) { return 0.006944444; }
                else if (to == areaUnitEnum.SquareInches) { return 1; }
                else if (to == areaUnitEnum.SquareKilometers) { return 6.4516 * Math.Pow(10, -10); }
                else if (to == areaUnitEnum.SquareMeters) { return 0.00064516; }
                else if (to == areaUnitEnum.SquareMiles) { return 2.490976686 * Math.Pow(10, -10); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 645.16; }
                else if (to == areaUnitEnum.SquareYards) { return 0.00077160493827; }
            }
            else if (from == areaUnitEnum.SquareKilometers)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 10000000000; }
                else if (to == areaUnitEnum.SquareFeet) { return 10763910.417; }
                else if (to == areaUnitEnum.SquareInches) { return 1550003100; }
                else if (to == areaUnitEnum.SquareKilometers) { return 1; }
                else if (to == areaUnitEnum.SquareMeters) { return 0.09290304; }
                else if (to == areaUnitEnum.SquareMiles) { return 0.38610215855; }
                else if (to == areaUnitEnum.SquareMillimeters) { return 1 * Math.Pow(10, 12); }
                else if (to == areaUnitEnum.SquareYards) { return 1195990.0463; }
            }
            else if (from == areaUnitEnum.SquareMeters)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 10000; }
                else if (to == areaUnitEnum.SquareFeet) { return 10.763910417; }
                else if (to == areaUnitEnum.SquareInches) { return 1550.0031; }
                else if (to == areaUnitEnum.SquareKilometers) { return .000001; }
                else if (to == areaUnitEnum.SquareMeters) { return 1; }
                else if (to == areaUnitEnum.SquareMiles) { return 3.8610215855 * Math.Pow(10, -7); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 1 * Math.Pow(10, 6); }
                else if (to == areaUnitEnum.SquareYards) { return 1.1959900463; }
            }
            else if (from == areaUnitEnum.SquareMiles)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 25899881103; }
                else if (to == areaUnitEnum.SquareFeet) { return 27878400; }
                else if (to == areaUnitEnum.SquareInches) { return 4014489599.9; }
                else if (to == areaUnitEnum.SquareKilometers) { return 2.589988110; }
                else if (to == areaUnitEnum.SquareMeters) { return 2589988.110; }
                else if (to == areaUnitEnum.SquareMiles) { return 1; }
                else if (to == areaUnitEnum.SquareMillimeters) { return 2.589988110 * Math.Pow(10, 12); }
                else if (to == areaUnitEnum.SquareYards) { return 3097600; }
            }
            else if (from == areaUnitEnum.SquareMillimeters)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return .01; }
                else if (to == areaUnitEnum.SquareFeet) { return 0.00001076391; }
                else if (to == areaUnitEnum.SquareInches) { return 0.0015500031; }
                else if (to == areaUnitEnum.SquareKilometers) { return 1 * Math.Pow(10, -12); }
                else if (to == areaUnitEnum.SquareMeters) { return 0.000001; }
                else if (to == areaUnitEnum.SquareMiles) { return 3.8610215855 * Math.Pow(10, -13); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 1; }
                else if (to == areaUnitEnum.SquareYards) { return 0.00000119599; }
            }
            else if (from == areaUnitEnum.SquareYards)
            {
                if (to == areaUnitEnum.SquareCentimeters) { return 8361.2736; }
                else if (to == areaUnitEnum.SquareFeet) { return 9; }
                else if (to == areaUnitEnum.SquareInches) { return 1296; }
                else if (to == areaUnitEnum.SquareKilometers) { return 0.00000083612736; }
                else if (to == areaUnitEnum.SquareMeters) { return 0.83612736; }
                else if (to == areaUnitEnum.SquareMiles) { return 3.2283057852 * Math.Pow(10, -7); }
                else if (to == areaUnitEnum.SquareMillimeters) { return 836127; }
                else if (to == areaUnitEnum.SquareYards) { return 1; }
            }
            return -999; //error code that it could not find the conversion

        }
コード例 #2
0
 public double GetAreaConversion(areaUnitEnum from, areaUnitEnum to)
 {
     if (from == areaUnitEnum.SquareCentimeters)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(0.001076391);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(0.15500031);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(1 * Math.Pow(10, -10));
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.0001);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(3.8610215855 * Math.Pow(10, -11));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(100);
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(0.000119599);
         }
     }
     else if (from == areaUnitEnum.SquareFeet)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(929.0304);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(144);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(9.290304 * Math.Pow(10, -8));
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.09290304);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(3.5870006428 * Math.Pow(10, -8));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(92903);
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(0.1111);
         }
     }
     else if (from == areaUnitEnum.SquareInches)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(6.4516);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(0.006944444);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(6.4516 * Math.Pow(10, -10));
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.00064516);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(2.490976686 * Math.Pow(10, -10));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(645.16);
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(0.00077160493827);
         }
     }
     else if (from == areaUnitEnum.SquareKilometers)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(10000000000);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(10763910.417);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(1550003100);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.09290304);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(0.38610215855);
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(1 * Math.Pow(10, 12));
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(1195990.0463);
         }
     }
     else if (from == areaUnitEnum.SquareMeters)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(10000);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(10.763910417);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(1550.0031);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(.000001);
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(3.8610215855 * Math.Pow(10, -7));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(1 * Math.Pow(10, 6));
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(1.1959900463);
         }
     }
     else if (from == areaUnitEnum.SquareMiles)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(25899881103);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(27878400);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(4014489599.9);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(2.589988110);
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(2589988.110);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(2.589988110 * Math.Pow(10, 12));
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(3097600);
         }
     }
     else if (from == areaUnitEnum.SquareMillimeters)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(.01);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(0.00001076391);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(0.0015500031);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(1 * Math.Pow(10, -12));
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.000001);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(3.8610215855 * Math.Pow(10, -13));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(1);
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(0.00000119599);
         }
     }
     else if (from == areaUnitEnum.SquareYards)
     {
         if (to == areaUnitEnum.SquareCentimeters)
         {
             return(8361.2736);
         }
         else if (to == areaUnitEnum.SquareFeet)
         {
             return(9);
         }
         else if (to == areaUnitEnum.SquareInches)
         {
             return(1296);
         }
         else if (to == areaUnitEnum.SquareKilometers)
         {
             return(0.00000083612736);
         }
         else if (to == areaUnitEnum.SquareMeters)
         {
             return(0.83612736);
         }
         else if (to == areaUnitEnum.SquareMiles)
         {
             return(3.2283057852 * Math.Pow(10, -7));
         }
         else if (to == areaUnitEnum.SquareMillimeters)
         {
             return(836127);
         }
         else if (to == areaUnitEnum.SquareYards)
         {
             return(1);
         }
     }
     return(-999); //error code that it could not find the conversion
 }