As from comments you have 2 options, ref and out
1)
private void assign(ref int num)
{
num = 10;
}
private void doSomething()
{
int num = 0;
assign(ref num);
MessageBox.Show(num.ToString());
}
2)
private int assign(out int num)
{
num = 10;
}
private void doSomething()
{
var num = 0;
assign(out num);
MessageBox.Show(num.ToString());
}
Normally this is done by returning the value:
private int assign(int input)
{
//some complicated calculation on input.
return 10;
}
private void doSomething()
{
var num = 0;
num = assign();
MessageBox.Show(num.ToString());
}