NOTE: I need only the output. Please give both theanswers. Thanks for your help.
5. Read the following code snippet:
class S {
public S() { Console.Write("S() ");}
}
class T : S {
public T() { Console.Write("T() ");}
}
class A {
public A() { Console.Write("A() ");}
}
class B : A {
public B() { Console.Write("B() ");}
}
class C {
private T t = new T();
public C() { Console.Write("C() ");}
}
class D : C {
private B x = new B();
public D() {Console.Write("D() "); } public static void Main() {
new D();
} } // Main方法和类D定义结束
The output will be:
6. Analyze the following code snippet:
public static void Main() {
string[] arr = {"One", "Two","Three",
"Four","Five","Six", "Seven"}; List<string> a1 = new List<string>();a1.AddRange(arr);
a1.Remove("Three");a1.RemoveAt(5);
a1.Insert(a1.IndexOf("Four"), "3"); a1.Insert(a1.Count, "OK");
a1.Sort((a,b) => -a.CompareTo(b));//所有元素排序:升还是降?
foreach(string s ina1) Console.Write("{0} ", s);
}
The output will be:
NOTE: I need only the output. Please give both the answers. Thanks for your help. 5. Read the following code snippet: cl
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am