Does the order of attributes have any guarantees?

前端 未结 3 698
情歌与酒
情歌与酒 2020-12-20 11:56

If multiple attributes are applied to a member, e.g.

[Foo]
[Bar]
void Baz() { ... }

Then are any guarantees made by the CLR/.NET specificat

3条回答
  •  抹茶落季
    2020-12-20 12:44

    Relying on ordering for this sort of thing is generally a bad idea. If the order is important, I would give the attribute a Priority property so that it can be made very explicit.

    I don't know of any guarantees that they will be retrieved in the original order.

提交回复
热议问题