Home

The StoreItem Library

 

Introduction

This is a library used by various articles on this site. These are the steps to create it.

Practical Learning Practical Learning: Creating the StoreItem Library

  1. To create a new project, on the main menu, click File -> New -> Project...
  2. In the Project Types list of the Add New Project dialog box, click Visual C# Projects
  3. In the Templates list, click Class Library
  4. Change the Name to StoreItem
     
  5. Click OK
  6. Change the file as follows:
     
    using System;
    
    namespace StoreItem
    {
    	/// <summary>
    	/// Summary description for CStoreItem:
    	/// This class is used to identify an object sold in a store
    	/// An item is identified by its Item Number, its Item Name,
    	/// its Item Size, and its Unit Price
    	/// </summary>
    	[Serializable]
    	public class CStoreItem
    	{
    		private string  nbr;
    		private string  nm;
    		private string  sz;
    		private decimal uprice;
    
    		public CStoreItem()
    		{
    			nbr = "";
    			nm  = "";
    			sz  = "";
    			uprice = 0.00M;
    		}
    
    		CStoreItem(string number, string name, string size, decimal price)
    		{
    			nbr    = number;
    			nm     = name;
    			sz     = size;
    			uprice = price;
    		}
    
    		public string ItemNumber
    		{
    			get { return nbr; }
    			set { nbr = value; }
    		}
    	
    		public string ItemName
    		{
    			get { return nm; }
    			set { nm = value; }
    		}
    		
    		public string Size
    		{
    			get { return sz;}
    			set { sz = value; }
    		}
    
    		public decimal UnitPrice
    		{
    			get { return uprice; }
    			set { uprice = value; }
    		}
    	}
    }
  7. To create the library, in the Solution Explorer, right-click the StoreItem node and click Build
  8. Close Visual Studio .NET
 

Home Copyright © 2004-2010 FunctionX, Inc.