C
C#3y ago
Avis

Object that's passed in isn't recognized as an object?

using System;
using System.Collections.Generic;

class Program {
public static void Main (string[] args) {
List<Lot> auction = new List<Lot>();

mainMenu(auction);
}

public void mainMenu(List<Lot> lots) {
Lot currentLot = null;
...

}
}
using System;
using System.Collections.Generic;

class Program {
public static void Main (string[] args) {
List<Lot> auction = new List<Lot>();

mainMenu(auction);
}

public void mainMenu(List<Lot> lots) {
Lot currentLot = null;
...

}
}
I'm getting an error saying An object reference is required for the non-static field, method, or property 'Program.mainMenu(List<Lot>)' When I try to call mainMenu() in my main method. Am I not passing the auction variable correctly?
4 Replies
TheRanger
TheRanger3y ago
well u need an instance to call an instance method since its a non static method do u know what static means?
Avis
AvisOP3y ago
yes
TheRanger
TheRanger3y ago
then u should know what to do
Avis
AvisOP3y ago
oh wait mainMenu needs to be static thank you!

Did you find this page helpful?