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

  • Home
  • SEARCH
  • 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 703883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:52:48+00:00 2026-05-14T03:52:48+00:00

So I have a class that has the following member variables. I have get

  • 0

So I have a class that has the following member variables. I have get and set functions for every piece of data in this class.

public class NavigationMesh
{
    public Vector3 node;
    int weight;
    bool isWall;
    bool hasTreasure;

    public NavigationMesh(int x, int y, int z, bool setWall, bool setTreasure)
    {
        //default constructor
        //Console.WriteLine(x + " " + y + " " + z);
        node = new Vector3(x, y, z);

        //Console.WriteLine(node.X + " " + node.Y + " " + node.Z);

        isWall = setWall;
        hasTreasure = setTreasure;

        weight = 1;

    }// end constructor

    public float getX()
    {
        Console.WriteLine(node.X);
        return node.X;
    }
    public float getY()
    {

        Console.WriteLine(node.Y);
        return node.Y;
    }
    public float getZ()
    {
        Console.WriteLine(node.Z);
        return node.Z;
    }

    public bool getWall()
    {
        return isWall;
    }

    public void setWall(bool item)
    {
        isWall = item;
    }

    public bool getTreasure()
    {
        return hasTreasure;
    }


    public void setTreasure(bool item)
    {
        hasTreasure = item;
    }

    public int getWeight()
    {
        return weight;
    }

}// end class

In another class, I have a 2-Dim array that looks like this

NavigationMesh[,] mesh;

mesh = new NavigationMesh[502,502];

I use a double for loop to assign this, my problem is I cannot get the data I need out of the Vector3 node object after I create this object in my array with my “getters”.

I’ve tried making the Vector3 a static variable, however I think it refers to the last instance of the object. How do I keep all of these object in memory? I think there being garbage collected. Any thoughts?

  • 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-05-14T03:52:48+00:00Added an answer on May 14, 2026 at 3:52 am

    In C#, don’t build get and set functions like that. Use a property:

    public float X
    {
       get {Console.WriteLine(node.X); return X;}
    }
    
    public bool IsWall {get;set;}
    

    If you have a reference to these items, they are not garbage collected.

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

Sidebar

Related Questions

I have a class that has the following property that is generated by the
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I have a Class that has a private variable with a public setter/getter function:
I have a class that has several member classes as attributes. The constructor of
I have a class that has a vector member variable, which I fill up
I have the following code that is able to create a class that has
I have the following piece of code: class Student { public: Student(){} void display()
Let's say I have a class that has a member which is an array.
I have a class that has an inner struct/class (I have decided which yet,
I have a class that has a property that I need to stub. I

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.