PART I
C h a p t e r 1 7 :
R u n t i m e T y p e I D , R e f l e c t i o n , a n d A t t r i b u t e s
483
PART IPART I
}
Console.WriteLine();
}
}
}
Here is the output produced by the program:
Using: MyClass
Constructing MyClass(int).
Values are x: 10, y: 10
Invoking methods on reflectOb.
Calling Sum
Result is 20
Calling IsBetween
14 is not between x and y
Calling Set
Inside Set(int, int). Values are x: 9, y: 18
Calling Set
Inside Set(double, double). Values are x: 1, y: 23
Calling Show
Values are x: 1, y: 23
The operation of the program is straightforward, but a couple of points are worth mentioning.
First, notice that only the methods explicitly declared by
MyClass
are obtained and used.
This is accomplished by using the
Do'stlaringiz bilan baham: |