A public enum in one class from another class : Enum : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » Enum »

 

A public enum in one class from another class









    

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
//
//  Enum.cs - Demonstrates using a public enum in one class from
//            another class
//
//             Compile this program with the following command line:
//                 C:>csc enum.cs
//
namespace nsEnum
{
    using System;
    public class Enum
    {
//  Define the enum type
        public enum Weekdays
        {
                Sun, Mon, Tues, Wed, Thurs, Fri, Sat, Count
        }
        static public void Main ()
        {
            clsSecond second = new clsSecond();
            second.ShowEnum ();
        }
    }
    class clsSecond
    {
        public void ShowEnum()
        {
//  Use the class name with the enum name
            Console.WriteLine ("Tuesday is day {0} in the week",
                                (int) Enum.Weekdays.Tues);
        }
    }
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» Enum