I'm doing a project in Windows Forms with webapi. I would get a value of a textBox when the call is made from webapi.
Below is the code snippet, but it does not work as it gives the error after the code.
namespace TCCWindows
{
public partial class FormPrincipal : Form
{
public static string PegarCoordenadas()
{
return edtLatitudeGMS.Text + " | " + edtlngGMS.Text;
}
}
public class GPSController : ApiController
{
public string Posicao()
{
return TCCWindows.FormPrincipal.PegarCoordenadas();
}
}
}
Error:
Error 2 An object reference is required for the non-static field, method, or property 'TCCWindows.FormPrincipal.edtLatitudeGMS' I:\C#\TCC\TCCWindows\FormPrincipal.cs 224 20 TCCWindows
Error 3 An object reference is required for the non-static field, method, or property 'TCCWindows.FormPrincipal.edtlngGMS' I:\C#\TCC\TCCWindows\FormPrincipal.cs 224 50 TCCWindows