C
C#

help

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

AAvis2/4/2023
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?
TTheRanger2/4/2023
well u need an instance to call an instance method since its a non static method do u know what static means?
AAvis2/4/2023
yes
TTheRanger2/4/2023
then u should know what to do
AAvis2/4/2023
oh wait mainMenu needs to be static thank you!

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ .Net Maui [Problem with Tab from TabBar]So i have a css and a tabbar with 2 tabs in it both linked to a css styling file yet i can't seem to❔ Calling async methodHi guys. I tried to call this AzureAPI class in main program. But I got a error. I want to call thibuild errors in my functioni want to call the function until the loop ends but its giving me build errors that I'm not 100% sur❔ View cannot be found.LoginModel.cs Pages/Account/Login.cshtml Pages/Account/Register.cshtml AccountController.cs attache❔ Unsupported Media Type - Razor page```{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","st✅ JsonConvert debugging helpHello! I'm having a hard time figuring out how to solve an issue where JsonConvert.DeserializeObject❔ Make a sprite follow mouse while pivoting around character in UnityHi, I its hard to describe my issue by describing it since im not sure exactly what I'm looking for ❔ is Generic Repository a bad implementation of Repository Pattern?Surfing the internet I have found several articles that say it is an anti-pattern because it is an a❔ Problems with using Dotnet 6 on Windows to publish to an exe formatDotnet/C# newb here. Previously I've only done a small amount of development using the **.Net Framew❔ Using net7 documentation while targeting netstandard2.0This might be a bit of a dumb question, but is there anyway to make omnisharp/roslyn's tooltips use ❔ WPF app unit testingI am learning how to make unit tests. I built my app on .net core 6.0 and I created class library (o❔ where exactly should i put authorizationso i read a few posts on where to put authorization and most of the people agree on putting it in th❔ C# WPF playing background musicHello, I have WPF app for game launcher/updater. I wanted to add background music, so I added this cC# wpf mvvm Datagrid filter using LINQSo here I have a MVVM form. the Form contains a Datagrid which is connected to the Databank. I also ❔ Is it worth to create lazy dictionary in this case?I have following class: so as you see Add function add to the dictionary class TreeNode, it looks li❔ Going to use a listbox with a switch for something in the morning, need help with format for bothI would like to set two variables with a listbox using a switch and one variable with a second listb