Nested class in component

E

Edward Diener

I want to create a nested class within my component class. The nested class
will have public properties. Naturally I want those properties to be
serialized just as those properties of my component are serialized. Should
my nested class be:

1) A struct, with my component class holding a value variable for it.
2) A class, with my component class holding a reference variable for it.

If the latter, does the nested class need to be derived from
System.ComponentModel.Component also ?
 
N

Nicholas Paldino [.NET/C# MVP]

Edward,

The nested class can be anything you want it to be. The serialization
aspects will not really make a difference. You just have to be aware of the
semantics. If it is a reference that your class holds, and you pass the
reference around, then changes made to the object that reference points to
will be reflected in the main class. With a value type, it will be copied
upon assignment.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top