Liste aller Codebeispiele
Ein Beispiel zum Einsatz der Klasse System.Math aus der .NET-Klassenbibliothek.
Autor: Dr. Holger Schwichtenberg
Beschreibung
Diese Klasse stellt zwei mathematische Konstanten (e und pi) sowie eine Reihe von mathematischen Funktionen bereit: Abs(), Acos(), Asin(), Atan(), Atan2(), Ceiling(), Cos(), Cosh(), Exp(), Floor(), IEEERemainder(), Log(), Log10(), Max, Min(), Pow(), Round(), Sign(), Sin(), Sinh(), Sqrt(), Tan(), Tanh().
Alle Mitglieder dieser Klasse sind statisch.
Programmcodebeispiele Visual Basic .NET (VB.NET)
Sub math1()
Dim m As System.Math
Dim x, y As Double
x = 2.234
y = m.Sin(x)
out("Sin(" & x & ") = " & y)
out("gerundet " & m.Round(y, 2))
y = m.PI
out("PI=" & y)
End Sub
Programmcodebeispiele CSharp (C#)
using System;
using System.Collections;
namespace FCL_Buch._System {
/// <summary>
/// Zusammenfassung für Math.
/// </summary>
public class Samples_Math {
public ArrayList Math1() {
// Beispiel für Math-Klasse
ArrayList result = new ArrayList();
double x = 2.234;
double y = Math.Sin(x);
FclOutput.PrintOut( "Sin(" + x.ToString() + ") = " + y.ToString() );
FclOutput.PrintOut( "gerundet " + Math.Round( y, 2 ).ToString() );
y = Math.PI;
FclOutput.PrintOut( "PI=" + y );
return result;
}
}
}
Querverweise
Definition '.NET Framework Class Library'
Verfügbarkeit der Klasse 'System'
Übersicht über den FCL-Namensraum 'System'
Portal dotnetframework.de
|
|