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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:19:43+00:00 2026-06-07T20:19:43+00:00

Here is my class pax public class pax { public pax(); [SoapElement(DataType = integer)]

  • 0

Here is my class pax

 public class pax
    {
        public pax();

        [SoapElement(DataType = "integer")]
        public string age { get; set; }
        public string firstName { get; set; }
        public string lastName { get; set; }
        public string paxType { get; set; }
        public string title { get; set; }
    }

and i have declare the following array

pax[][]rooms=new pax[3][];

        rooms[0][0].paxType = "Adult";
        rooms[0][1].paxType="Adult";
        rooms[0][2].paxType="Child";
        rooms[0][2].age = "6";

Its throwing an error Object reference not set to an instance of an object. on line

 rooms[0][0].paxType = "Adult";
  • 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-07T20:19:45+00:00Added an answer on June 7, 2026 at 8:19 pm

    This will only give you array.

    pax[][]rooms=new pax[3][];
    

    To instantiate object, you have to new it:

    rooms[0][0] = new pax();
    

    You might be coming from C++ and may think that object array automatically create all objects, but that’s not the case here – you will have to create each one because it is null before you do it.

    EDIT:

    Since you have jagged array here:

    pax[][]rooms=new pax[3][];
    rooms[0]=new pax[3];
    rooms[0][0]=new pax();
    

    Jagged array = array of arrays. If you need multidimensional (2-dimensional array), that’s different story, and you would say:

    pax[,] rooms=new pax[3,3];
    

    for example…

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

Sidebar

Related Questions

I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{
Here is my class (product.cs) where is the method to insert the image: public
See this code here: class test { int n; int *j; public: test(int m)
I've got this here class defined in a header file: class E_IndexList { public:
I'm trying to write a mysql class... enter code here class ASQL { public
I found this code here class Usable; class Usable_lock { friend class Usable; private:
Given the code from here : class lazy_init { mutable std::once_flag flag; mutable std::unique_ptr<expensive_data>
What am I doing wrong here: class Helo { // main: generate some simple
I have such class (sorry about posible mistakes, i'm writing it right here.) Class
template <bool, class t, class u>// why is bool here,class booltype=bool. Are they equivalent?

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.