You are creating an application that manages information about zoo animals. The application
includes a class named Animal and a method named Save.
The Save() method must be strongly typed. It must allow only types inherited from the Animal class
that uses a constructor that accepts no parameters.
You need to implement the Save() method.
Which code segment should you use?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Explanation:
When you define a generic class, you can apply restrictions to the kinds of types that client code can
use for type arguments when it instantiates your class. If client code tries to instantiate your class by
using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions
are called constraints. Constraints are specified by using the where contextual keyword.
http://msdn.microsoft.com/en-us/library/d5x73970.aspx
C
https://msdn.microsoft.com/en-us/library/d5x73970.aspx
Sadly the exam got updated this March, here’s the new dump for who’s doing the exam soon.
There’s like 20 new questions with a new case study.
http://megadownloder.com/70483ProgrammingInC
thank u Jun
where T : new() The type argument must have a public parameterless constructor. When used together with other constraints, the new() constraint must be specified last.