Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Enum changing

Posted on 2009-02-17
2
Medium Priority
?
231 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

0
Comment
Question by:u2envy1
2 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 2000 total points
ID: 23660240
because you r reinitializing the CommType variable in the line
 CommType = new CommunicationType();
0
 

Author Closing Comment

by:u2envy1
ID: 31547802
Thx, how could I miss that.....
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question