C
C#2y 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
TheRanger2y ago
well u need an instance to call an instance method since its a non static method do u know what static means?
Avis
AvisOP2y ago
yes
TheRanger
TheRanger2y ago
then u should know what to do
Avis
AvisOP2y ago
oh wait mainMenu needs to be static thank you!
Want results from more Discord servers?
Add your server