Enumerated Types with a base other than integer

I have code snippets that I have published that are scattered throughout the web. I am going to work at compiling a handfull of them here.


/// <summary>Indicates the forth byte of the machine’s host ip address. </summary>
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcreftheenumerationtypes.asp

/// Integral Types:
public enum ServerMachines : byte {
      /// <summary>The IP Address of the printer.
Printer = 114,
       /// <summary>The IP Address of the database server.
Database = 132,
      /// <summary>The IP Address of the web server.
Web = 243,
      /// <summary>The IP Address of the firewall.
Firewall = 1

/// <summary>Tests an enumerated type with a base-type other than the default integer. </summary>
class EnumTester {
private const string HOST_SUBNET_PREFIX = "192.168.0.";

      /// <summary> The main entry point for the application.</summary>
static void Main(string[] args) {
// Iterate through the server machines
foreach(byte address in Enum.GetValues(typeof(ServerMachines))) {
"The {0} server has an address of {1}{2}", 
Enum.GetName(typeof(ServerMachines), address), 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s