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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply