Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
BobJanova24-Mar-14 8:07
BobJanova24-Mar-14 8:07 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
Kenneth Haugland24-Mar-14 11:10
mvaKenneth Haugland24-Mar-14 11:10 
QuestionUsing nonce for authentication Pin
TygerBS24-Mar-14 2:21
TygerBS24-Mar-14 2:21 
AnswerRe: Using nonce for authentication Pin
Pete O'Hanlon24-Mar-14 3:17
mvePete O'Hanlon24-Mar-14 3:17 
QuestionDeveloping a C# Project Pin
Bobba Praneeth24-Mar-14 0:09
Bobba Praneeth24-Mar-14 0:09 
AnswerRe: Developing a C# Project Pin
Keith Barrow24-Mar-14 1:23
professionalKeith Barrow24-Mar-14 1:23 
AnswerRe: Developing a C# Project Pin
V.24-Mar-14 3:49
professionalV.24-Mar-14 3:49 
AnswerRe: Developing a C# Project Pin
BobJanova24-Mar-14 3:58
BobJanova24-Mar-14 3:58 
AnswerRe: Developing a C# Project Pin
OriginalGriff24-Mar-14 6:23
mveOriginalGriff24-Mar-14 6:23 
Question[solved] Array of classes nested into array of classes (and serialization) Pin
Mario 5623-Mar-14 22:23
Mario 5623-Mar-14 22:23 
AnswerRe: Array of classes nested into array of classes (and serialization) Pin
Pete O'Hanlon23-Mar-14 22:48
mvePete O'Hanlon23-Mar-14 22:48 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5623-Mar-14 23:43
Mario 5623-Mar-14 23:43 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Pete O'Hanlon24-Mar-14 2:23
mvePete O'Hanlon24-Mar-14 2:23 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 2:42
Mario 5624-Mar-14 2:42 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Pete O'Hanlon24-Mar-14 2:48
mvePete O'Hanlon24-Mar-14 2:48 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 5:54
Mario 5624-Mar-14 5:54 
AnswerRe: Array of classes nested into array of classes (and serialization) Pin
BobJanova24-Mar-14 4:14
BobJanova24-Mar-14 4:14 
There's two problems here which I think come from the same misunderstanding.

In C, the code
struct A {
 int someField;
 struct B {
  long somethingElse; }
 } B;
}

... defines an object tree. That is, I can say
A a;
a.B.somethingElse = 12L;


In C#, you have not written the equivalent. Nested classes (and structs) define only the class, they do not define a field that goes with it. The fact that they're nested only affect name resolution and visibility. You need to also provide a field or property that is linked to an instance or array of the inner class.

That means I think you want:
public class product
{
    public bool enabled;
    public string productName;
    public double zero;
    public double span;
    public string unit;
    public preProcessing[] pp;

    public class preProcessing
    {
        public string preProcessingName;        // preprcessing name
        public double[] param = new double[5];  // 5 parameters from preprocessing
    }
}


(Set aside for the moment questions of array vs list and public fields.) That means you can say

var p = new product();
p.pp = new product.preProcessing[10];
p.pp[0] = new product.preProcessing();
p.pp[0].param[3] = 12.8;


You've made the same mistake at the top level: Parameters should have a field of type product[].

When you do that you'll see the second mistake, because your code will stop compiling due to inconsistent [Serializable] attributes. You need to put [Serializable] on all the inner classes that are part of your data tree, too.
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 6:17
Mario 5624-Mar-14 6:17 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 7:44
Mario 5624-Mar-14 7:44 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
BobJanova24-Mar-14 8:05
BobJanova24-Mar-14 8:05 
GeneralRe: Array of classes nested into array of classes (and serialization) Pin
Mario 5624-Mar-14 10:24
Mario 5624-Mar-14 10:24 
QuestionRegarding Role based Login Pin
Member 1067835223-Mar-14 22:08
Member 1067835223-Mar-14 22:08 
SuggestionRe: Regarding Role based Login Pin
Richard MacCutchan23-Mar-14 23:01
mveRichard MacCutchan23-Mar-14 23:01 
GeneralRe: Regarding Role based Login Pin
Member 1067835224-Mar-14 18:28
Member 1067835224-Mar-14 18:28 
GeneralRe: Regarding Role based Login Pin
Richard MacCutchan24-Mar-14 22:23
mveRichard MacCutchan24-Mar-14 22:23 

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.