I created a function in C # as:
public void input_fields(int init_xcor, int init_ycor, char init_pos, string input) { char curr_position = 'n'; foreach (char c in input) { if (c == 'm') { Move mv = new Move(); if (curr_position == 'e' || curr_position == 'w') { init_xcor = mv.Move_Step(curr_position, init_xcor, init_ycor); } else { init_ycor = mv.Move_Step(curr_position, init_xcor, init_ycor); } } } }
and I call the function like:
input_fields(init_xcor, init_ycor, init_pos, input);
but when called, it gives an error:
An object reference is required for a non-static field, method or property "TestProject.Program.input_fields (intermediate, int, char, string) 'xxx \ TestProject \ Program.cs 23 17 TestProject
I do not want the function to be static, since I also need to do a unit test.
What should I do for this? ... Please help me.
source share