Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:33:20+00:00 2026-06-08T18:33:20+00:00

I am having trouble with this piece of code and I can’t figure out

  • 0

I am having trouble with this piece of code and I can’t figure out how to get it to work. I can’t figure out what the problem is as to me it looks like it should work. The string array called m_nameList on both places are marked as ‘An object reference required for the non static feild, method, or property ‘Solutionname.classname.m_nameList’

the code:

    public static bool CheckVacantSeats(int seatNumber)
    {            
        if (m_nameList[seatNumber] == null)
      {
          return true;
      }
      return false;
    }

m_nameList is an array that is declared in an constructor before this static bool:

     public SeatManager(int maxNumberOfSeats)
    {
        m_totNumOfSeats = maxNumberOfSeats;
        m_nameList = new string[m_totNumOfSeats];
        m_priceList = new double[m_totNumOfSeats];
    }   

I am calling the CheckVacantSeat from another class with this:

  bool validSeats = SeatManager.CheckVacantSeats(seatNumber, m_nameList);    

I can’t figure out what is wrong with it. So i need some help figuring out why m_nameList does not work for me?

Thanks in advance!!

//Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:33:21+00:00Added an answer on June 8, 2026 at 6:33 pm

    The problem is that you have marked your method as static. Since it is static, it has “no” state, and cannot access class members which are not marked as static.

    You can mark m_nameList as static, but that means that it’s value is shared across all reads and writes. m_nameList looks like a simple lookup table so maybe this is what you want?

    Recommended reading is static and Static Classes and Static Members.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting the following piece of code to work out. I
I'm having a small bit of trouble trying to get this piece of code
I am having trouble getting this invisibilityOfElementLocated() method to work. Here is the code
I'm having trouble with a piece of code $(function(){ $('input.no').click(function(){ $(this).animate({left : 80px}, 150);
I'm having trouble converting this piece of code (originally in VB) to C#. In
I am having trouble with this piece of code below. Whenever I run this
I have two issues with this piece of code. I 'm having trouble because
I'm learning Python, and I'm having trouble with this simple piece of code: a
I'm having a little trouble with making the following piece of code work. I
I'm having some trouble with a particular piece of code, if anyone can enlighten

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.