本文整理汇总了VB.NET中System.Math.Sqrt方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Math.Sqrt方法的具体用法?VB.NET Math.Sqrt怎么用?VB.NET Math.Sqrt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Math
的用法示例。
在下文中一共展示了Math.Sqrt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
Module Example
Public Sub Main()
' Create an array containing the area of some squares.
Dim areas() As Tuple(Of String, Double) =
{ Tuple.Create("Sitka, Alaska", 2870.3),
Tuple.Create("New York City", 302.6),
Tuple.Create("Los Angeles", 468.7),
Tuple.Create("Detroit", 138.8),
Tuple.Create("Chicago", 227.1),
Tuple.Create("San Diego", 325.2) }
Console.WriteLine("{0,-18} {1,14:N1} {2,30}", "City", "Area (mi.)",
"Equivalent to a square with:")
Console.WriteLine()
For Each area In areas
Console.WriteLine("{0,-18} {1,14:N1} {2,14:N2} miles per side",
area.Item1, area.Item2, Math.Round(Math.Sqrt(area.Item2), 2))
Next
End Sub
End Module
输出:
City Area (mi.) Equivalent to a square with: Sitka, Alaska 2,870.3 53.58 miles per side New York City 302.6 17.40 miles per side Los Angeles 468.7 21.65 miles per side Detroit 138.8 11.78 miles per side Chicago 227.1 15.07 miles per side San Diego 325.2 18.03 miles per side
示例2: Tester
Public Class Tester
Public Shared Sub Main
Dim magnitude As Single
Dim radians As Single
magnitude = CSng(Math.Sqrt(100 ^ 2 + 120 ^ 2))
radians = CSng(Math.Atan2(100, 123))
Console.WriteLine(magnitude)
Console.WriteLine(radians)
End Sub
End Class