DEV Community

Mushtariy
Mushtariy

Posted on

Value 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

Javob 100, chunki a ning qiymati 100 va u o'zgarmadi faqat a ning qiymati b ga ham tenglandi

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

Javob: BMW chunki car1 BMW ga teng va u o'zgarmadi faqat car2 ga uning nusxasi tenglandi string tiplarini qiymati hechqachon o'zgarmaydi.

Top comments (0)