Jason Isom
August 2nd, 2005, 07:54 PM
public class Foo
{
public static void Main()
{
int x = 100;
Bar b = new Bar(ref x);
b.func();
Console.WriteLine(x); // I'm trying/wanting this to output 110
}
}
public class Bar
{
private ref int y; // I am aware that this does not work
public Bar(ref int x)
{
y = x;
}
public void func()
{
x += 10;
}
}
Can I do anything to achieve this functionality? I know that it doesn't work this way...
The reason I ask is because if it's not possible, I'm going to have to rethink my design completely.
I posted earlier about my problem with maintaining multiple forms...and this is a continuation of that problem.
I have a couple of forms: a LoginForm and a MainForm.
What happens is that the user keeps trying to Login until he/she gets a successful login. At that time I'd like to pass the User structure I've created to the MainForm as an argument to the constructor.
Now this isn't that big of a problem because MainForm doesn't change anything in the User class, however MainForm eventually does create another form that does alter the User structure. Now it's important that it does change the original structure in LoginForm because when LoginForm calls the Closing event, it serializes my ArrayList of Users and it should be an updated ArrayList.
{
public static void Main()
{
int x = 100;
Bar b = new Bar(ref x);
b.func();
Console.WriteLine(x); // I'm trying/wanting this to output 110
}
}
public class Bar
{
private ref int y; // I am aware that this does not work
public Bar(ref int x)
{
y = x;
}
public void func()
{
x += 10;
}
}
Can I do anything to achieve this functionality? I know that it doesn't work this way...
The reason I ask is because if it's not possible, I'm going to have to rethink my design completely.
I posted earlier about my problem with maintaining multiple forms...and this is a continuation of that problem.
I have a couple of forms: a LoginForm and a MainForm.
What happens is that the user keeps trying to Login until he/she gets a successful login. At that time I'd like to pass the User structure I've created to the MainForm as an argument to the constructor.
Now this isn't that big of a problem because MainForm doesn't change anything in the User class, however MainForm eventually does create another form that does alter the User structure. Now it's important that it does change the original structure in LoginForm because when LoginForm calls the Closing event, it serializes my ArrayList of Users and it should be an updated ArrayList.