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

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    71

    how can I call value static field or method list type class

    If I have class with static field:
    Code:
    public class Cart
    {
            private static int quantity_all_books = 0; 
    
            public int id { get; private set; }
            public int quantity { get; private set; }
    
            public Cart(int x, int y)
            {
                quantity_all_books++;
    
                id = x;
                quantity = y;
            }
    }
    And I have list type of this class:
    Code:
    List<Cart> shopping = new List<Cart>();
    shopping.Add(new Cart(53, 2));
    shopping.Add(new Cart(44, 1));
    How can I check value static field quantity_all_books. I have tried make this field public, write method which return value of this field. But when I write "shopping." Visual Studio don't give me on the list this field or method.
    Last edited by abab; July 6th, 2009 at 03:44 AM.

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