Click here to Skip to main content
15,885,890 members
Home / Discussions / C#
   

C#

 
QuestionMethod, Class, Object Reference Pin
C-P-User-312-Nov-12 10:31
C-P-User-312-Nov-12 10:31 
Why does my attempt to use a method called "Start_Data_Command_04" in this file produce the stated error ? (I'll list the error immediately after the code)

File Name: Form1.cs
C#
namespace George_Washington
{
    public partial class Form1 : Form
    {
    ///Lots of other stuff
    ///
     ///


        /* *************************************************************************** *
         *  This button Will Start The Data Flood                                      *
         * *************************************************************************** */

        void Button4_Start_Data_Click(object sender, EventArgs e)
        {
            The_User_Clicked_A_Button_Called.Start_Data_Command_04(); ////Error Is here

        }
    }
}

Quote:
Error 2 An object reference is required for the non-static field, method, or property 'SerialPortPractice_03.The_User_Clicked_A_Button_Called.Start_Data_Command_04()'

The method named "Start_Data_Command_04" is located in this file, and produces an error (no clue if they are related) of its own...

File name: The_User_Clicked_A_Button_Called.cs
C#
namespace George_Washington
{
    public class The_User_Clicked_A_Button_Called
    {
        internal void Start_Data_Command_04()
        {
            UART.send_command 
                (////The Error Is Flagged right here
                Protocol_Packets_01.BARN_Command_04_Start_Data_Flood,
                0,
                Protocol_Packets_01.BARN_Command_04_Start_Data_Flood.Length
                )
                ;
        }
    }
}


Quote:
Error 1 An object reference is required for the non-static field, method, or property 'SerialPortPractice_03.UART.send_command(byte[], int, int)'


No matter what word I put in front of the method; e.g., internal, private, public, static, whatever; I still get an error.


The actual method in question is here
File Name: UART.cs
C#
namespace George_Washington
{
    class UART
    {
    
        public void send_command(byte[] The_Byte_Array, int Starting_Place, int Length)
        {
            The_Serial_Port_We_Are_Testing.Write(
                                                 The_Byte_Array, 
                                                 Starting_Place, 
                                                 Length
                                                 )
                                                 ;
        }

    
    }

}

AnswerRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 10:49
mvePete O'Hanlon12-Nov-12 10:49 
GeneralRe: Method, Class, Object Reference Pin
C-P-User-312-Nov-12 13:19
C-P-User-312-Nov-12 13:19 
GeneralRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 20:15
mvePete O'Hanlon12-Nov-12 20:15 
GeneralRe: Method, Class, Object Reference Pin
J4amieC12-Nov-12 21:36
J4amieC12-Nov-12 21:36 
GeneralRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 22:11
mvePete O'Hanlon12-Nov-12 22:11 
GeneralRe: Method, Class, Object Reference Pin
Simon_Whale12-Nov-12 22:06
Simon_Whale12-Nov-12 22:06 
GeneralRe: Method, Class, Object Reference Pin
fjdiewornncalwe13-Nov-12 3:49
professionalfjdiewornncalwe13-Nov-12 3:49 
GeneralRe: Method, Class, Object Reference Pin
C-P-User-313-Nov-12 8:06
C-P-User-313-Nov-12 8:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.