I'm researching someone else's code and there is a method like this:
public SomeClass DoSomething(string param1, [Optional, DefaultParameterValue("")] string optional)
Why would someone use these attributes instead of
public SomeClass DoSomething(string param1, string optional = "")
Is there any difference in the behavior, etc.?
If they weren't using C# 4, for example? I believe the second version will compile into exactly the first version...
(I've compiled them both and run them through ILDASM - there were no significant differences.)
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