CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: C# Design...

Threaded View

  1. #1
    Join Date
    May 2004
    Location
    Greenville, NC
    Posts
    193

    C# Design...

    Code:
    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.
    Last edited by Jason Isom; August 2nd, 2005 at 08:11 PM.
    Jason Isom
    .NET 2.0 / VS2005 Developer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured