DEV Community

Mushtariy
Mushtariy

Posted on

1 1 1 1 1

Value type va Reference type

a)Quyidagi kodning natijasini ayting va tushuntiring.

class Program
{
   static void Main(string args[])
   {
      int x = 10;
      int y = x;
      y = 20;
      Console.WriteLine(x);
   }
}

Enter fullscreen mode Exit fullscreen mode

Javob 10 chunki x ning qiymati 10 va bu qiymat o'zgarmagan.

b)Quyidagi kodning natijasini tushuntiring.

class Person
{
   public string Name;
}

class Program
{
   static void Main(string[] args)
   {
      Person p1 = new Person();
      p1.Name = "Alice";
      Person p2 = p1;
      p2.Name = "Bob";
      Console.WriteLine(p1.Name);
   }
}
Enter fullscreen mode Exit fullscreen mode

Javob:

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

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

Okay