We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Enum changing

u2envy1
u2envy1 asked
on
Medium Priority
240 Views
Last Modified: 2012-05-06
I have a Enum. When the code is excuting its showing TCP.
When entering a switch it changes.
Any ideas ?
It changes on
            terminalID = TerminalID;
Out side the class.....
UniBadger myBadge = new UniBadger(TerminalID, UniBadger.CommunicationType.TCP, 1111, "10.0.0.0"); 
 
 //Enum on ConnectionType
        public enum CommunicationType
        {
            SerialRS232,
            SerialRS485,
            TCP,
            Modem
        };
 
 public CommunicationType CommType;
 
     
        public UniBadger(int TerminalID, CommunicationType CommType, int Port,string IPAddress)
        {
            CommType = new CommunicationType();
            terminalID = TerminalID;
            switch (CommType)
            {               
                case CommunicationType.TCP:
 
                    mTCP_IP = new TCP_IP();
                    mTCP_IP.IPAddress = IPAddress;
                    mTCP_IP.Port = Port;
                    mCommand = new Command(mTCP_IP);
 
                    break;
 
                case CommunicationType.Modem:
 
                    break;
 
                default:
                    break;
            }
        }
 
        public UniBadger(int TerminalID, CommunicationType CommType, string COMport)//Serial Connection must have a COM port
        {
            CommType = new CommunicationType();
            terminalID = TerminalID;
            switch (CommType)
            {
                case CommunicationType.SerialRS232://Serial RS232 connection
 
                    mSerialRS232 = new SerialRS232();
                    mSerialRS232.PortName = COMport;
                    mSerialRS232.Connect();
                    mCommand = new Command(mSerialRS232);
 
                    break;
 
                case CommunicationType.SerialRS485://Serial RS485 connection
 
                    mSerialRS485 = new SerialRS485();
                    mSerialRS485.PortName = COMport;
                    mSerialRS485.Connect();
                    mCommand = new Command(mSerialRS485);
 
                    break;
 
                default:
                    break;
            }
        }

Open in new window

Comment
Watch Question

Technical Manager
Commented:
because you r reinitializing the CommType variable in the line
 CommType = new CommunicationType();

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thx, how could I miss that.....
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.