J
Jeff0803
Guest
I want to pass constuector argument by ref and make that value changed in the instance of the class.
I made simple example like following.
public class MyClass
{
private int m_ID;
public MyClass(ref int ID)
{
m_ID = ID;
}
public void AddValue()
{
m_ID = m_ID + 100;
}
}
class Program
{
static void Main(string[] args)
{
int id;
id = 1;
MyClass myclass = new MyClass(ref id);
myclass.AddValue();
Console.WriteLine("id = {0}", id);
}
}
This example's result is "id = 1".
I need to make it "id = 101".
How to do that?
Continue reading...
I made simple example like following.
public class MyClass
{
private int m_ID;
public MyClass(ref int ID)
{
m_ID = ID;
}
public void AddValue()
{
m_ID = m_ID + 100;
}
}
class Program
{
static void Main(string[] args)
{
int id;
id = 1;
MyClass myclass = new MyClass(ref id);
myclass.AddValue();
Console.WriteLine("id = {0}", id);
}
}
This example's result is "id = 1".
I need to make it "id = 101".
How to do that?
Continue reading...