NOTE: I need only the output. Please give both theanswers. Thanks for your help.
3. Read the following code snippet:
public class TestStatic {
private static intcx; //小写的(cx) static TestStatic() {
Console.Write("static TestStatic();"); cx = 0;
}
public static int CX { //大写的(CX)
get {Console.Write("get;"); return cx; } set { Console.Write("set;"); cx= value; }
}
public static voidMain() { Console.Write("Main();"); CX = 1;
Console.Write(CX + " ");
}
}
The output will be:
4. Analyze the following code snippet:
public classTestExchange { public static void Main() {
int i = 101, j =-99; Exchange(i, j);
Console.Write ("i ={0}, j = {1}; ", i, j); Exchange<int>(ref i, ref j);Console.Write ("i = {0}, j = {1}.", i, j);
}
static voidExchange(int x, int y) { int temp;
temp = x; x = y; y = temp;
}
static voidExchange<T>(ref T x, ref T y) where T : struct { T temp;
temp = x; x = y; y = temp;
}
}
The output will be:
NOTE: I need only the output. Please give both the answers. Thanks for your help. 3. Read the following code snippet: pu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am