Comma oneliner attribute?

Today I noticed something strange that I thought at first, did not compile:

[Serializable Obsolete]
class Program
{
    static void Main(string[] args)
    {
    }
}

Note that there is no comma between serializable and deprecated. This gives an error, but it still compiles !. Why is this? Do attributes even work like this?

+4
source share
1 answer

It seems Rene has already said that resharper gives this error. I suspended the rescuer, and now I'm not mistaken at all. So this is apparently a perfectly fine syntax in C # for attributes.

Why resharper gives this error, I do not know, however. Of course, this may be a strange syntax and against conventions, but that warns of errors.

0
source

Source: https://habr.com/ru/post/1654009/


All Articles