// The above line has the following error when I run the program
// Error = System.NullReferenceException was unhandled
// Message="Object reference not set to an instance of an object."
class product
{
public String Code;
public String Description;
public List<batch> Batch;
}
class batch
{
public Int64 Cost;
public Int64 Rebate;
public Int64 Freight;
}
Batch is a List of batch objects. Being a list, it's a reference type. You must allocate memory for it, otherwise it's just a null reference, hence your error.
I was just doing that when you were posting your comment. Thankyou very much for your help. When you say that I'm not following the naming conventions, is that because I am using the same name for the class type and the list, but in different case?
I'm sorry for the stupid questions but I am very new
It's not a stupid question. Yes, the name for your classes start with lower letters. That is because the name of the property collides with the name of the class. But you should name the property Batches instead, because it's a list of batches, not a single batch.
Code:
class Product
{
public String Code;
public String Description;
public List<Batch> Batches;
}
class Batch
{
public Int64 Cost;
public Int64 Rebate;
public Int64 Freight;
}
Then you should mention than and marked the threads resolved so that we don't waste the time providing answers that you already have.
or so that we know we can find an answer there. it would be so cool if everyone did that
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
Bookmarks