Page 1 of 1

NOTE: I need only the output. Please give both the answers. Thanks for your help. public struct Point { //class Point??

Posted: Fri Jul 01, 2022 5:33 am
by answerhappygod
NOTE: I need only the output. Please give both theanswers. Thanks for your help.
public struct Point{ //class Point?? public int x;
public int y;
public override string ToString(){
return string.Format("({0},{1}) ", x,y);
}
}
public classTestPoint { static void Main() {
Point p1 = newPoint(); //p1 p1.x = 99;
p1.y = 101;
Point p2 =p1; //p2 p2.x = -99;
p2.y = -101;
Console.WriteLine("p1:{0}; p2{1}", p1,p2);
}
}
The output will be:
2. Read the following code snippet:
public class A {
private string str= "Year:2021"; static void NewString(string str)
{ str = "Year:2022"; } static void NewString(A a)
{ a.str = "Year:2023"; } static void Main() {
string str = "NewYear"; A a = new A();
NewString(str);
NewString(a);
Console.WriteLine("str = {0}; a.str ={1}",
str, a.str);
} } // Main方法和类A 定义结束
The output will be: