New course! Every coder should learn Generative AI!
Try a free lesson0
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); }
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#