От: | BokiyIS | ||
Дата: | 12.07.08 22:49 | ||
Оценка: |
10.3.3 Inheritance
A class inherits the members of its direct base class type. Inheritance means that a class implicitly contains all members of its direct base class type, except for the instance constructors, destructors and static constructors of the base class.
class Program
{
static void Main(string[] args)
{
Console.WriteLine(B._str);
}
}
class A
{
public static string _str = "test";
}
class B: A {}
Console.WriteLine(A._str);
10.12 Static constructors
...
The execution of a static constructor is triggered by the first of the following events to occur within an application domain:
• An instance of the class type is created.
• Any of the static members of the class type are referenced.
public class A
{
public static string str = Init();
public static void Yell()
{
Console.WriteLine(">> Yell");
}
private static string Init()
{
return ">> Init";
}
static A()
{
}
}
public class EntryPoint
{
static void Main()
{
A.Yell();
}
}
>> Yell