class definition

  • Thread starter Thread starter c676228
  • Start date Start date
C

c676228

Hi all,

What is the exact difference between these two defintion?
public class ClassName
public new class ClassName

The second question is relevant to []. I am not so used to
[Serializable] or [PrimaryKey(true)] before a specific definition, will you
guide me?

Thanks,

public class Customer : ClassBase
{

}



[Serializable]
public new class State : StateBase
{
[PrimaryKey(true)]
public int? customerID = null;

}
 
c676228 said:
What is the exact difference between these two defintion?
public class ClassName
public new class ClassName

http://msdn.microsoft.com/en-us/library/435f1dw2.aspx

has a description.
The second question is relevant to []. I am not so used to
[Serializable] or [PrimaryKey(true)] before a specific definition, will you
guide me?
[Serializable]
public new class State : StateBase
{
[PrimaryKey(true)]
public int? customerID = null;

}

Serializable means the object can be saved and loaded again
by a serializer/deserializer.

PrimaryKey must be an attribute used by some ORM
framework to indicate the field is primary key in
the database table. I can identify which framework.

Arne
 
Thank you so much Arne and Peter for the explain and

those two links about new modifier and attributes are very helpful.
--
Betty


Peter Duniho said:
[...]
The second question is relevant to []. I am not so used to
[Serializable] or [PrimaryKey(true)] before a specific definition, will
you
guide me?

In addition to what Arne wrote, the "[<identifier>]" syntax is known as an
"attribute". It's a way of including some meta-data with language
objects, to provide for additional automatic behavior.

In the particular examples you've given, they relate to serialization and
database relationships, but there are code attributes for a wide variety
of purposes.

See here for more details:
http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx

Pete
 
Greetings to all!

Arne and Peter, thanks for your proactive posting and helping each other in
the newsgroup. We cannot develop such a good newsgroup community without
warmhearted and good-tech members like you. I do very appreciate your input
here!

And Betty, if you have any future questions or concerns, please let me know
and I will provide future support on this.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
Back
Top