Beruflich Dokumente
Kultur Dokumente
March 3, 2015
BSCE 4
Math Methods
Method Name
Description
Math.Abs
Absolute Value
Math.Acos
Math.Asin
Math.Atan
Math.Atan2
Math.BigMul
Math.Ceiling
Math.Cos
Math.Cosh
Math.DivRem
Math.E
Constant e value
Math.Equals
Math.Exp
Math.Floor
Math.IEEERemain
der
Math.Log
Math.Log10
Math.Max
Math.Min
Example
Math.Abs(-1);
1
Math.Acos(.45);
1.10403.
Math.Asin(.56);
0.59438..
Math.Atan(.64);
0.56931..
Math.Atan2(.56, .64);
0.71882.
Math.BigMul(12345,6789);
83810205
Math.Ceiling(1.12);
2
Math.Cos(53);
-0.918283..
Math.Cosh(8);
1490.47916..
Math.DivRem(100, 3, out c);
33, 1
Math.E;
2.718281..
Math.Equals(1, 4);
False
Math.Exp(2);
7.38905.
Math.Floor(1.23);
1
Math.IEEERemainder(5.46,
4.34);
1.12
Math.Log(3, 5);
0.6826061
Math.Log10(2);
0.301029
Math.Max(5, 78);
78
Math.Min(5, 78);
5
Math.PI
PI value
Math.Pow
Math.ReferenceE
quals
Math.Round
Math.Sign
Math.Sin
Math.Sinh
Math.Sqrt
Math.Tan
Math.Tanh
Math.Truncate
Math.PI;
3.1415926.
Math.Pow(2, 4);
16
Math.ReferenceEquals(100, 56);
False
Math.Round(.78);
1
Math.Sign(-.89);
-1
Math.Sin(87);
-.0.8218178
Math.Sinh(57);
2.842859.
Math.Sqrt(144);
12
Math.Tan(45);
1.619775
Math.Tanh(65);
1
Math.Truncate(88.8);
88
Sample Programs
Program 1:
Program 2:
using System;
using System;
class Program1
{
static void Main()
{
long c;
class Program1
{
static void Main()
{
double x = Math.Truncate(88.8);
Console.WriteLine(x);
Console.Read();
}
Console.Read();
Output:
88
Output:
33, 1
String Methods
Method Name
String.Compare
String.CompareOr
dinal
String.Concat
String.Copy
String.Equals
String.Format
String.Intern
String.IsInterned
String.InNullorEmp
ty
String.IsNullOrWhi
teSpace
String.Join
String.ReferenceE
quals
Description
Compares two
specified String objects and returns
an integer that indicates their
relative position in the sort order
Compares two
specified String objects by
evaluating the numeric values of the
corresponding Char objects in each
string
Creates the string representation of
a specified object
Creates a new instance
of String with the same value as a
specified String
Determines whether this instance
and another specified String object
have the same value
Replaces one or more format items
in a specified string with the string
representation of a specified object
Retrieves the system's reference to
the specified String
Retrieves a reference to a
specified String
Indicates whether the specified
string is null or an Empty string
Indicates whether a specified string
is null, empty, or consists only of
white-space characters
Concatenates the elements of an
object array, using the specified
separator between each element
Determines whether the specified
instances are the same instance
Example
String.Compare(sat, sat);
0
String.CompareOrdinal(sat,
Sat);
32
String.Concat(Hello ,
there);
Hello there
String.Copy(Hello);
Hello
String.Equals(hi, Hi);
False
String.Format("(\"{0}\")
String.Intern(s2);
String.IsInterned(value);
String.IsNullOrEmpty(s);
String.IsNullOrWhiteSpace(null,
String.Empty, "ABCDE")
True, True, False
String.Join(/, His, Her);
His/Her
String.ReferenceEquals(Her,
Him);
False
Sample Programs:
Program 1:
using System;
class Program1
{
static void Main()
{
string x = String.Join(" ", "Camille", "Sequitin");
Output:
Camille Sequitin
Console.WriteLine(x);
Console.Read();
}
Program 2:
using System;
class Program1
{
static void Main()
{
Console.WriteLine(String.CompareOrdinal("sat", "Sat"));
Console.Read();
}
Output:
32