-3

I am trying the following code:

NMEAData = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";

byte[] bData = new byte[256];

bData = Encoding.ASCII.GetBytes(NMEAData);
***NMEAProtocol.ParseBuffer(bData);***

public void ParseBuffer( byte[] buffer)
{
    foreach (byte b in Globals.GBuffer)
    {
        ProcessNMEA(b);
    }
    return;
 }

When trying to compile I am getting

CS0120: An object reference is required for the non-static field, method, or property

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Sharon
  • 31
  • 7
  • Please provide code that is realitevly correct but demonstrates the problem. Code in current state only allow guesses. – Alexei Levenkov Nov 13 '15 at 06:10
  • If I convert this method to static, all the code under need to be converted to be static. How to I create just an object of that class and how do I invoke it as an object instance? – Sharon Nov 13 '15 at 06:10
  • Side note: please avoid "thank you" and "searched alot" text in the post. To demonstrate search effort make sure to provide article/answers you've found and how it did not work in your case (I've removed all text not related to the problem from your post). – Alexei Levenkov Nov 13 '15 at 06:11

1 Answers1

0

NMEAProtocol is not a static class. You need to instantiate it:

NMEAProtocol protocol = new NMEAProtocol(); // not sure about constructor. see documentation
protocol.ParseBuffer(bData);

In this case, reading articles online it not enough to fix the problem.
It is a basic, fundamental language knowledge.

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101