This doesn't seem possible, but I'll ask anyway... Is it possible in C# to apply a single attribute to multiple fields at once?
public class MyClass {
[SomeAttribute]
public int m_nVar1;
[SomeAttribute]
public int m_nVar2;
public int m_nVar3;
}
Is there a short-hand method to put the "SomeAttribute" on m_Var1 & m_Var2, but not on m_nVar3? Currently, we are placing the attributes before each field, but it would be nice to put all the fields using a attribute inside a block.
Yes, it's possible:
[SomeAttribute]
public int m_nVar1, m_nVar2;
(but obviously only if the types are the same)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With