Click here to Skip to main content
15,905,504 members
Home / Discussions / C#
   

C#

 
GeneralRe: Search object in hierarchy object (class) Pin
Heath Stewart5-Jul-04 10:08
protectorHeath Stewart5-Jul-04 10:08 
QuestionHow to compare MemoryStream? Pin
god4k5-Jul-04 5:57
god4k5-Jul-04 5:57 
AnswerRe: How to compare MemoryStream? Pin
Heath Stewart5-Jul-04 10:01
protectorHeath Stewart5-Jul-04 10:01 
GeneralRe: How to compare MemoryStream? Pin
Mike Dimmick5-Jul-04 13:44
Mike Dimmick5-Jul-04 13:44 
GeneralRe: How to compare MemoryStream? Pin
Heath Stewart5-Jul-04 17:58
protectorHeath Stewart5-Jul-04 17:58 
GeneralRe: How to compare MemoryStream? Pin
god4k5-Jul-04 14:30
god4k5-Jul-04 14:30 
AnswerRe: How to add custom properties in PropertyGrid at Runtime Pin
Heath Stewart5-Jul-04 5:11
protectorHeath Stewart5-Jul-04 5:11 
GeneralHowto Delete a file at run time!?! Pin
QzRz5-Jul-04 4:45
QzRz5-Jul-04 4:45 
GeneralRe: Howto Delete a file at run time!?! Pin
Heath Stewart5-Jul-04 4:50
protectorHeath Stewart5-Jul-04 4:50 
GeneralRe: Howto Delete a file at run time!?! Pin
QzRz5-Jul-04 5:09
QzRz5-Jul-04 5:09 
GeneralRe: Howto Delete a file at run time!?! Pin
Heath Stewart5-Jul-04 5:12
protectorHeath Stewart5-Jul-04 5:12 
GeneralRe: Howto Delete a file at run time!?! Pin
QzRz5-Jul-04 5:15
QzRz5-Jul-04 5:15 
GeneralRe: Howto Delete a file at run time!?! Pin
Heath Stewart5-Jul-04 5:19
protectorHeath Stewart5-Jul-04 5:19 
GeneralRe: Howto Delete a file at run time!?! Pin
QzRz5-Jul-04 5:25
QzRz5-Jul-04 5:25 
GeneralRe: Howto Delete a file at run time!?! Pin
Colin Angus Mackay5-Jul-04 5:57
Colin Angus Mackay5-Jul-04 5:57 
GeneralRe: Howto Delete a file at run time!?! Pin
QzRz5-Jul-04 9:53
QzRz5-Jul-04 9:53 
GeneralRe: Howto Delete a file at run time!?! Pin
Jeremy Falcon5-Jul-04 10:14
professionalJeremy Falcon5-Jul-04 10:14 
GeneralRe: Howto Delete a file at run time!?! Pin
Colin Angus Mackay5-Jul-04 11:06
Colin Angus Mackay5-Jul-04 11:06 
GeneralObject reference not set to an instance of an object Pin
rturner0035-Jul-04 4:34
rturner0035-Jul-04 4:34 
I am using the article Inserting XML formatted data into SQL Server 2000 By faisal abdul aziz as a template for some work I doing. I have create a class, in a separate class file, to cover the 'child' elements. I have called this Answers.cs.

The begining of the file looks like this:

using System;
using System.Xml.Serialization;

namespace SGC.Apps.Consultations
{

public class Answers
{
public Answers()
{
}

private int intQNo;
private int intAns;

[XmlAttribute]
public int Question_No {
get {
return this.intQNo;
}
set {
intQNo = value;
}
etc.....

In web form I have button_click event routine
private void Button1_Click(object sender, System.EventArgs e) {
if (Page.IsValid) {
XmlSerializer serlizer = new XmlSerializer(typeof(Replies));
int intCount = 2;
Answers[] ans = new Answers[intCount];
ans[1].Question_No = 3;

etc......

I get the error Object reference not set to an instance of an object
The highlighted line is 'ans[1].Question_No = 3;

Full error is [NullReferenceException: Object reference not set to an instance of an object]

Can anyone help with what stupid thing I am doing wrong?

cheers



Robert T Turner
South Gloucestershire Council
GeneralRe: Object reference not set to an instance of an object Pin
Colin Angus Mackay5-Jul-04 4:43
Colin Angus Mackay5-Jul-04 4:43 
GeneralRe: Object reference not set to an instance of an object Pin
Heath Stewart5-Jul-04 4:53
protectorHeath Stewart5-Jul-04 4:53 
GeneralRe: Object reference not set to an instance of an object Pin
exhaulted5-Jul-04 5:00
exhaulted5-Jul-04 5:00 
GeneralRe: Object reference not set to an instance of an object Pin
rturner0035-Jul-04 5:54
rturner0035-Jul-04 5:54 
Generalupdating label in main form Pin
Jason Ranin5-Jul-04 4:16
Jason Ranin5-Jul-04 4:16 
GeneralRe: updating label in main form Pin
exhaulted5-Jul-04 4:24
exhaulted5-Jul-04 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.