1 // Test various kinds of arrays as custom attribute parameters
9 class FooAttribute
: Attribute
11 public string [] StringValues
;
12 public object [] ObjectValues
;
13 public EnumType
[] EnumValues
;
16 public FooAttribute ()
21 [Foo (StringValues
= new string [] {"foo", "bar", "baz"}
,
22 ObjectValues
= new object [] {1, 'A', "B"}
,
23 EnumValues
= new EnumType
[] { EnumType.X, EnumType.Y }
,
24 Types
= new Type
[] {typeof (int), typeof (Type)}
28 public static int Main ()
30 FooAttribute foo
= (FooAttribute
) typeof (Test
)
31 .GetCustomAttributes (false) [0];
32 if (foo
.StringValues
[0] != "foo"
33 || foo
.StringValues
[1] != "bar"
34 || foo
.StringValues
[2] != "baz"
35 || 1 != (int) foo
.ObjectValues
[0]
36 || 'A' != (char) foo
.ObjectValues
[1]
37 || "B" != (string) foo
.ObjectValues
[2]
38 || EnumType
.X
!= foo
.EnumValues
[0]
39 || EnumType
.Y
!= foo
.EnumValues
[1]
40 || foo
.Types
[0] != typeof (int)
41 || foo
.Types
[1] != typeof (Type
)