2 questions; why does the first code outputs 15 and also, why does the second code outputs 3 instead of 4? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

2 questions; why does the first code outputs 15 and also, why does the second code outputs 3 instead of 4?

class Class { public int x=12; public int X { get { return ++x; } set { x=++value; } } } static void Main() { Class c = new Class(); c.X = c.X; Console.Write(c.X); } class Temp { public int dgre=2; public Temp() { dgre++; } ~Temp() { dgre++; } } static void Main(string[] args) { Temp t = new Temp(); Console.Write(t.dgre); }

21st Jun 2022, 7:58 PM
eMBee
eMBee - avatar
1 Answer
0
David (DonDejvo) So what's the better way I should have written the code? Let me make some quick improvements in C#
21st Jun 2022, 8:18 PM
eMBee
eMBee - avatar