Click here to Skip to main content
12,397,027 members (66,616 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads

Stats

28.3K views
232 downloads
14 bookmarked
Posted

Refactoring a Switch Statement

, 15 Aug 2009 CPOL
Avoiding a switch statement in order to avoid Cyclomatic complexity.
Refactoring-Switch
Refactoring-Switch
bin
Debug
Refactoring-Switch.exe
Refactoring-Switch.vshost.exe
Properties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Refactoring_Switch
{
    class Program
    {
        static void Main(string[] args)
        {
            DeviceController deviceController = new DeviceController();
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            deviceController.ChangeDeviceState(DeviceStatesEnum.Active);
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            deviceController.ChangeDeviceState(DeviceStatesEnum.PowerUp);
            Console.WriteLine(deviceController.GetDeviceState().ToString());
            Console.Read();
        }


    }

    public enum DeviceStatesEnum
    {
        PowerUp,
        Waiting,
        StandBy,
        Inactive,
        Active,
        Start,
        Ready,
        Equilibrating,
        StartRunning,
        Running,
        ShoutingDown,
        ShoutDown,
        WarmingUp,
        Error
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

rajeshjj
Software Developer (Senior) MphasiS an HP company
India India
I am dotnet programmer

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 15 Aug 2009
Article Copyright 2009 by rajeshjj
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid