We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Question about declaring a class

Peter Kiers
Peter Kiers asked
on
Medium Priority
303 Views
Last Modified: 2013-12-16
Hi,

I have found some code on the internet that i am trying to understand.

f.e: this line:
private ProductDatabase DataClass = new ProductDatabase();

How should I interpreted this line of code?

Peter

Comment
Watch Question

CERTIFIED EXPERT

Commented:
it is a private class member instantiation.

by default this variable is only available to the class that it is declared in
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
private = declares that this member/variable is only for the use of the class in which it is declared.
ProductDatabase - declaring the type of this class member
DataClass - naming this instance of the class ProductDatabase
new ProductDatabase() - assigns the default value to the new instantiation through a constructor.
Peter KiersOperator

Author

Commented:
Oke thank you, but what I don't understand is f.e. this line in the code of the loadevent:

        private void MainForm_Load(object sender, EventArgs e)
        {
            TreeNode nodeParent;
            foreach (DataRow row in DataClass.GetCategories().Rows) <===================
            {
                nodeParent = lstvFoodDB.Nodes.Add(row[ProductDatabase.CategoryField.Name].ToString());
                 nodeParent.ImageIndex = 0;
                nodeParent.Tag = row;
                nodeParent.Nodes.Add("*");
            }
        }

Shouldn't this be: ...... ProductDatabase.GetCategories().Rows)

P.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Peter KiersOperator

Author

Commented:
Oke now I understand. Thanks p_davis.

P.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.