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 9036571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:02:13+00:00 2026-06-16T09:02:13+00:00

I want to wrap List class with my custom class. As for now I

  • 0

I want to wrap List class with my custom class. As for now I have something like this ;

public class PriorityListOfNodes
{

    private List<Node>          list_;
    private IComparer<Node>     sorter_;

    public List<Node> List_ {
            get {return list_;}
            set {list_ = value;}
    }

    public PriorityListOfNodes ()
    {
            sorter_ = new NodeSorter_fValueDescending ();
    }

    public Node PopFromEnd ()
    {
            Node temp = new Node (list_ [list_.Count - 1]);
            list_.RemoveAt (list_.Count - 1);
            return temp;
    }

    public Node PeekFromEnd ()
    {
            return list_ [list_.Count - 1];
    }

    public void Add (ref Node toAdd)
    {
            Debug.Log (toAdd);
            list_.Add (toAdd);
            list_.Sort (sorter_);
    }
}

When I do now

Node temp = new Node(10,20); //custom constructor
PriorityListOfNodes l = new PriorityListOfNodes();
l.add(temp); 

I get runtime exception :

Object reference not set to an instance of an object

I have also tried without ref but with the same result. What am I doing wrong here ?

  • 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-16T09:02:14+00:00Added an answer on June 16, 2026 at 9:02 am

    You never actually instantiate a List<Node>.

     public PriorityListOfNodes ()
        {
                sorter_ = new NodeSorter_fValueDescending ();
                list_ = new List<Node>();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of MyItem objects called myItems like this: public class MyItem{
I have a custom list adapter. Here it is: public class FilesAdapter extends ArrayAdapter<PutioFileLayout>
I have a couple of POJOs which looks like this: class Items { List<Item>
I want to wrap around a list/vector in C++ like in Python. Basically I
I want to display some div's in a wrap. The div have same class
I have a list of boost::tuple . I want to expose this tuple list
I have a list view that looks like this and that's its code ..
I have a list of items of a custom class. That class contains an
Consider the following class: public class MyIntSet { private List<int> _list = new List<int>();
I have this code public class MyFragment extends SherlockFragment { public static Fragment newInstance(Context

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.