Results 1 to 2 of 2

Thread: Accessing Another Class' Methods

Threaded View

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Accessing Another Class' Methods

    Hi All,

    I have created the attached demo project as an example of some principles that I am trying to learn and incorporate into my code. I have attached this code example.

    I have a class called Person and in this class I have a method called SetSkinColor. SetSkinColor opens up a form, the user enter some values, when they leave a text box the values are processed by another method in my Person class called AddSkinColors. AddSkinColors takes the colors adds them together, saves the result to a member variable and returns the result to the calling class.

    *** I hope I explain this right ***
    I was having a tough time trying to figure out a way to call a method from the same class that called the form class. The only way I was able to figure this out was to create a public object on the form of type Person and then the SetSkinColor method would be able to add a reference of its class to the form.

    In light of the note: “Avoid using many member variables. Declare local variables and pass it to methods instead of sharing a member variable between methods. If you share a member variable between methods, it will be difficult to track which method changed the value and when.” at this web site http://www.dotnetspider.com/Technolo...Practices.aspx

    I am wondering if I really should be coding this way.

    Is this OK or should I be looking to do this another way?

    Thanks Steve
    Attached Files Attached Files
    This space for rent...

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