© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
7 replies
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>)'
An object reference is required for the non-static field, method, or property 'Program.mainMenu(List<Lot>)'
When I try to call
mainMenu()
mainMenu()
in my main method. Am I not passing the
auction
auction
variable correctly?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Retrieving an object that's indirectly related in RazorPages
C#CC# / help
4y ago
❔ what's an object?
C#CC# / help
3y ago
Displaying in App isn't working as intended.
C#CC# / help
15mo ago
Object passed by reference unexpectedly
C#CC# / help
12mo ago