Case Study

We conclude this survival guide with a somewhat larger example that illustrates the concepts we have already discussed and also introduces a few additional features of C#. Our example is a version of the Stock Management System that we have used as a case study throughout the second part of this book. The sample code is in the folder StockManager.

StockDefs.cs

The file StockDefs.cs defines an enumeration, a structure, and an interface that are used in the system.

// StockDefs.cs

using System.Collections;

public enum ItemStatus :  byte
{
   NotFound,   // 0 implicitly
   NotEnough,  // 1 implicitly
   Ok = 5      // explicit value
}

public struct StockItemStruct
{
   public int Id;
   public string Name;
   public int Count;
}

public interface IStock { int AddItem(string ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.