Why isn't my new object being seen? C#

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-03-29T08:30:09Z Indexed on 2010/03/29 8:33 UTC
Read the original article Hit count: 415

Filed under:
|

I am getting ready to take a class at a college on C#. I have been reading up on it a lot and decided to start a fun project.

Here is what my project consists of:

  • Main Control Form
  • Configuration Form
  • Arduino

Program.cs calls Configuration.cs at start. This is where pin modes for the Arduino are set and where a timer is set. When I set these values, they get sent to MainControl.cs. When I hit the "Save" button in Configuration.cs, a MainControl.cs object is created [[I am correct in that?]]

All of those values that were sent by Configuration.cs had corresponding setters that set private static variables in MainControl.cs [[ I don't really know if that is the preferred way, I am most definetly open to any suggestion anyone has]]

MainControl.cs uses its default constructor, and this constructor calls a method that creates an arduino object from one of the private variables (serialPort) [[ Using this Arduino class Firmata.NET ]]

When the arduino object is created, I know (I guess I do) because the form takes a few seconds to come up (As opposed to not using serial port) My problem is this:

I do not understand why nothing can see the object

I have been very wordy, I apologize if I wasn't concise. Here is the code:

public partial class CMainControl : Form
{
       private static string serialPort;
        public CMainControl()
    {
        InitializeComponent();
        createArduino();
        updateConfig();  // Change label values to values set in configuration
    }

    private void createArduino()
    {
        Arduino arduino = new Arduino(serialPort);
    }

In Configuration.cs, when I set the serial port through a combobox, the value is sent to MainControl.cs just fine.

Here is the error I get:

Error 1 The name 'arduino' does not exist in the current context C:\Programming\Visual Studio\Workhead Demo\Workhead Demo\CMainControl.cs 94 13 Workhead Demo

Please let me know if anyone can help and/or offer pointers, and please let me know if I didn't post or format anything correctly.

Thank you very much :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about objects