Advertisement

05.13.2008 at 08:19PM PDT, ID: 23400184
[x]
Attachment Details

c# array

Asked by asif07 in C# Programming Language

In a web service, i am trying to create an array of objects of on of my classes but i am getting a run-time error when i invoke the object.

At line
books[i] = objBook;

The objBook has the first object values, but when I assign it to the books object, I get an object reference null exception.

I am confused at this point!!!

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Book[] b = null;
Book[] tempBook;
tempBook.Length = 7
for(int i =0; i< tempBook.Length; i++)
            {
                
                Book b = tempBook[i];
                Book objBook = new Book(b.ISBN);
 
                books[i] = objBook;
            }
[+][-]05.13.2008 at 08:30PM PDT, ID: 21561042

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 08:34PM PDT, ID: 21561061

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 08:52PM PDT, ID: 21561134

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 08:54PM PDT, ID: 21561140

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 09:01PM PDT, ID: 21561160

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 10:02PM PDT, ID: 21561379

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C# Programming Language
Sign Up Now!
Solution Provided By: naspinski
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628