本文整理匯總了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