Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Here is the following code. I have a class, and access it in my main form.

 

Part of my class comGPIB

public class comGPIB
{
	Board brd = new Board();
	Device devdev = new Device(0,0);
	public int iHELLO;
	public Device [] devGPIB = new Device[5];
	public bool boolPSConnected;
	public enum Dev {PS=0, AGSwitch1=1, AGSwitch2=2, KeithleyMM=3};// Used for which array for devGPIB
	public enum PS {Agilent=0,Xantrex=1}; //Used when for which Power Supply is found on the GPIB Network
}

 

And here is the code from my main form

 

comGPIB cGPIB = new comGPIB();// this is up at the top where my variables are

private void btnPractice_Click(object sender, System.EventArgs e)
	{
		
		string readIt = cGPIB.readGPIB(cGPIB.devGPIB[1]);			
		this.lblPract.Text = readIt;
	}

 

When I do cGPIB. in the drop down box I can see the public integer and the public boolean variable, but not the enums I created.

 

Now when I do this I see it and it work, by putting the namespace.

int i = HBAS_PVFT_Rack.comGPIB.Dev.AGSwitch1;

 

Is there an explanation for this? I tried reading the help files and didn't see anything on why I need the namespace for the enum in that class.

 

Thanks,

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted
Thanks, yes I do see other little bugs, as when I am typing the index cursor stays in one spot while the letters are being typed. At first I kept thinking I hit something for it to go back. Unfortunatley I don't have the luxury of my company getting the latest. Plus I won't be working here too much longer as they are closing the facility and moving to China. Maybe my next job I can get the newer version.
Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
  • Leaders
Posted
I think the issue here is that in one case you are trying to access the enum through a variable (cGPIB), and in the other case you are accessing the enum through the type (comGPIB). The enum is not a member of the class. It is a nested type.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...