DEV Community

Sunnat Qayumov
Sunnat Qayumov

Posted on

3 2 2 2 2

19. Valu va Reference Type

*a) Quyidagi kodning natijasini tushuntiring: *

int a = 100;
int b = a;
b = 200;
Console.WriteLine(a);
Enter fullscreen mode Exit fullscreen mode

bu kodda int tipida a nomli o'zgaruvchi e'lon qilinadi va uni 100 ga tenglaymiz. keyin int tipida yana b nomli o'zgaruvchi e'lon qilib uni a o'zgaruvchiga tenglab qo'yamiz. keyin b o'zgaruvchiga 200 ni tenglab qo'yamiz. Keyin Console.WriteLine() kalit so'zi orqali a ni consolga chop etamiz. Javob: 100.

*b) Quyidagi kodni natijasini ayting va tushuntiring: *

class Car
{
    public string Model;
}
Car car1 = new Car();
car1.Model = "BMW";
Car car2 = car1;
car2.Model = "Audi";
Console.WriteLine(car1.Model);
Enter fullscreen mode Exit fullscreen mode

Car nomli class yaratamiz. Uni ichida Model nomli object yaratamiz. classdan tashqarida car1 nomli o'zgaruvchi yaratamiz. Keyin car1 ga BMW nomli stringni saqlaymiz. Keyin Car classdan yana car2 nomli o'zgaruvchi e'lon qilamiz va unga car1 ni saqlaymiz. Keyin car2 ga Audi nomli stringni saqlaymiz. Keyin Console.WriteLine() kalit so'zi orqali car1 ni consolga chop etamiz.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay