4
Answers

Problem with structure

Rohan M

Rohan M

17y
1.9k
1

Hi to all, Plz help me
Can we assign the intger value in an object again and again?

using System;

struct MyStruct

{

   public int x = 25;

   public void SetX(int i)

   { x = i; }

}

class MyClient

{

 public static void Main()

  {

    MyStruct ms = new MyStruct();

    ms.SetX(100);

  // Store this object somewhere(say arraylist) then again collect this object and

  // assign different value. 

    ms.SetX(102);

  }

}

Answers (4)