// , static Cons() {
alpha = 99;
Console.WriteLine(" .");
}
// , public Cons() {
beta = 100;
Console.WriteLine(" .");
class ConsDemo {
static void Main() {
Cons ob = new Cons();
Console.WriteLine("Cons.alpha: " + Cons.alpha);
Console.WriteLine("ob.beta: " + ob.beta);
}
}
.
.
.
Cons.alpha: 99 ob.beta: 100
, static , , . : . , , , .
static. . -, . -, . , static.
static class _ { 11...
static. , , .
. -, . LINQ 19. -, . .
NumericFn static , . NumericFn static, static, . , NumericFn , .
// .
static class NumericFn {
// , static public double Reciprocal(double num) { return 1/num;
}
// , static public double FracPart(double num) { return num - (int) num;
}
// true, // num , static public bool IsEven(double num) { return (num % 2) ==0? true: false;
}
// true, // num , static public bool IsOdd(double num) { return!IsEven(num);
|
|
}
}
class StaticClassDemo { static void Main() {
Console.WriteLine(" 5 " +
NumericFn.Reciprocal(5.0));
Console.WriteLine(" 4.234 " +
NumericFn.FracPart(4.234));
If(NumericFn.IsEven(10))
Console.WriteLine("10 .");
If(NumericFn.IsOdd(5))
Console.WriteLine("5 .");
// NumericFn, // .
// NumericFn ob = new NumericFn(); // !
}
}
.
5 0.2 4.234 0.234
.
.
, . NumericFn , . NumericFn.
: , , .