Ilkin Turk

Ilkin Turk

  • NA
  • 242
  • 78.3k

c# return value throug params keyword

May 18 2014 6:09 AM
Hello ,
in below method - How to return value with params keyword.It is possible if change Do method return type to int.But I need to do it with void and params keyword.
Thanks in advance.

 private void button1_Click(object sender, EventArgs e)
        {
            int x = 1;
            Do(x);
            MessageBox.Show(x.ToString());
        }


        public void Do(params object [] paramet )
        {
            int value = (int)paramet[0];
            value = value + 2;
         
          
        }

Answers (6)