O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

1:List three kinds of data abstractions where structs should be considered instead of classes.
2:Mention the important similarities and differences between classes and structs.
3:If myStruct is a value type, how is the following call possible if WriteLine only accepts reference types?
Console.WriteLine("Details of myStruct" + myStruct);
4:Can a struct have an explicit default constructor?
5:Why is boxing called boxing?
6:Suppose the struct Fraction contains the two public data members numerator and denominator. Fraction does not contain any explicitly defined constructors. You now write the following code:
Fraction myFraction;
myFraction.ToString();

Is the second line valid? Why or why not?

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required