[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Question about declaring a class

Posted on 2011-04-29
6
Medium Priority
?
291 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

0
Comment
Question by:peterkiers
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 35491313
it is a private class member instantiation.

by default this variable is only available to the class that it is declared in
0
 
LVL 3

Assisted Solution

by:Mrugesh1
Mrugesh1 earned 800 total points
ID: 35491327
private ProductDatabase DataClass = new ProductDatabase();

- private ProductDatabase indicates ProductDatabase is the private access class.
- ProductDatabase is the class name
- DataClass is the class object


0
 
LVL 22

Expert Comment

by:p_davis
ID: 35491337
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:peterkiers
ID: 35491440
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.
0
 
LVL 22

Accepted Solution

by:
p_davis earned 1200 total points
ID: 35491452
if getcategories was a static method yes but it appears that it is public, in which case this syntax would be correct.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 35491485
Oke now I understand. Thanks p_davis.

P.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question