当前位置: 首页>>代码示例>>C#>>正文


C# Distance.ToFeet方法代码示例

本文整理汇总了C#中Distance.ToFeet方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.ToFeet方法的具体用法?C# Distance.ToFeet怎么用?C# Distance.ToFeet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Distance的用法示例。


在下文中一共展示了Distance.ToFeet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToFeetWorksCorrectly

        public void ConvertToFeetWorksCorrectly()
        {
            // Arrange
            const double Millimeters = 112345d;
            const double Feet = 368.585958d;

            // Act
            var distance = new Distance(Millimeters);

            // Assert
            Assert.IsNotNull(distance);
            Assert.AreEqual(Feet, Math.Round(distance.ToFeet(), 6));
        }
开发者ID:kwilson,项目名称:dotnet-distance,代码行数:13,代码来源:ImperialTests.cs

示例2: TestConvertion

        public void TestConvertion()
        {
            // Create an object with 5 m
            Distance dist = new Distance(5, DistanceUnit.Meters);

            Assert.AreEqual(5, dist.Value);
            Assert.AreEqual(DistanceUnit.Meters, dist.Units);

            Distance feet = dist.ToFeet();
            Assert.AreEqual(16.4041995, feet.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.Feet, feet.Units);

            Distance meters = dist.ToMeters();
            Assert.AreEqual(5, meters.Value);
            Assert.AreEqual(DistanceUnit.Meters, meters.Units);

            Distance mm = dist.ToMillimeters();
            Assert.AreEqual(5000, mm.Value);
            Assert.AreEqual(DistanceUnit.Millimeters, mm.Units);

            Distance cm = dist.ToCentimeters();
            Assert.AreEqual(500, cm.Value);
            Assert.AreEqual(DistanceUnit.Centimeters, cm.Units);

            Distance inch = dist.ToInches();
            Assert.AreEqual(196.850394, inch.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.Inches, inch.Units);

            Distance km = dist.ToKilometers();
            Assert.AreEqual(0.005, km.Value);
            Assert.AreEqual(DistanceUnit.Kilometers, km.Units);

            Distance miles = dist.ToStatuteMiles();
            Assert.AreEqual(0.00310685596, miles.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.StatuteMiles, miles.Units);

            Distance nm = dist.ToNauticalMiles();
            Assert.AreEqual(0.00269978402, nm.Value, 0.00001);
            Assert.AreEqual(DistanceUnit.NauticalMiles, nm.Units);
        }
开发者ID:rowetechinc,项目名称:RTI,代码行数:40,代码来源:DistanceTest.cs


注:本文中的Distance.ToFeet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。