What is a value class?

M

Marc

I am studying something and a question in a book talks about value class.
What should be that? I trying to figure it out, but google gives too many
non relevant answers and sentences containing these two words. If somebody
would know this by hearth it would be a help. I thought struct is a value
type and class is a reference type, so neither a 'reference struct' nor a
'value class' would exists.

It's just a silly question in a book:

You need to create a simple class or structure that contains only value
types. You must create the class or structure so that it runs as efficiently
as possible. You must be able to pass the class or structure to a procedure
without concern that the procedure will modify it. Which of the following
should you create?

A reference class
B reference structure
C value class
D value structure

Correct Answer: D

A Incorrect: You could create a reference class; however, it could be
modified when passed to a procedure.
B Incorrect: You cannot create a reference structure.
C Incorrect: You could create a value class; however, structures tend to be
more efficient.
D Correct: Value structures are typically the most efficient.

I understand C is the correct anwer, but what would 'reference structure'
but also 'value class' be? Well they confirm that reference structure is non
existant nonsence, but the term value class seems to be something. Huh?

I am starting to think the book just has an error in it. :)
 
P

Peter Duniho

Marc said:
[...]
I understand C is the correct anwer, but what would 'reference
structure' but also 'value class' be? Well they confirm that reference
structure is non existant nonsence, but the term value class seems to be
something. Huh?

I am starting to think the book just has an error in it. :)

Sounds like you're using the same crappy studdy materials about which
Tony Johansson has been peppering us with questions. You may find some
value, rather than asking questions that come up, in just browsing
through all the threads he's started here. :)

As far as the specific question goes, you're correct…in C#, there is
nothing specifically defined to be a "value class".

From context, it appears they may consider a class containing only
value types to be a "value class". But for the author to be consistent,
they then would have to allow "reference struct" (i.e. a structure
containing only reference types). And frankly, the distinction between
a class containing only value types and one that has reference types is
IMHO pointless.

I'll give you the same advice I offered Tony: go find something better
to study with. That book stinks.

Pete
 
M

Marc

Peter Duniho said:
Sounds like you're using the same crappy study materials about which Tony
Johansson has been peppering us with questions.

It's the selfstudy material for the '536' exam.
I'll give you the same advice I offered Tony: go find something better to
study with. That book stinks.

Yes...As far as I have seen and found on the web, a lot more people are
saying this book has lots and lots of errors. And that for an official MS
exam selfstudy book, it's dissapointing.

I got other stuff too.
 
S

Sajjad Hasan

It is an old thread, but may I say that the author may be referring to an Immutable class.
 
S

Sajjad Hasan

It is an old thread, but may I say that the author may be referring to an Immutable class.
 

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