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
487
PART IPART I
Positional vs. Named Parameters
In the preceding example,
RemarkAttribute
was initialized by passing the description
string to the constructor, using the normal constructor syntax. In this case, the
comment
parameter to
RemarkAttribute( )
is called a
positional parameter.
This term relates to the fact
that the argument is linked to a parameter by its position in the argument list. This is the way
that all methods and constructors work in C#. For example, given a method called
test( )
,
declared as shown here:
void test(int a, double b, string c)
the following call to
test( )
test(10, 1.1, "hello");
passes 10 to
Do'stlaringiz bilan baham: |