Reason #462 Why I don't like VB.NET:
VB.NET attributes cannot have variable arguments. What do I mean?
The following code does NOT work in VB.NET:
Public Class MyCustomAttribute
Inherits Attribute
Public Sub New(ByVal ParamArray vals() As String)
End Sub
End Class
It compiles, but when you try to use this attribute on a member you’ll get an error: “Attribute constructor argument is a 1-dimension array of string which is not Integral, float, etc…..”
In C# this works perfectly fine. Why is this?
To provide a workaround for this issue I just accept a single pipe-delimited string and .Split it on the pipe to get my array. A tad on the ugly side, but it works.
Now playing: Third Eye Open - Intolerance
I'm Ben Scheirman. I am a .NET software developer with a strong interest in agility. I work as a Principal Consultant with Sogeti.
Read more here.
email me
Ads by The Lounge
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.