The C # specification (17.2) states that when specifying an attribute, there are several target attributes. This is often the case when you need to apply an attribute to something that often has a βrealβ place to specify the attribute. For example, the return target is often used in the Invoke platform:
[return: MarshalAs(UnmanagedType.Bool)] static extern bool SomeWin32Method();
However, I noticed that there are other attribute targets, such as method :
[method: DllImport("somelib.dll")] static extern bool SomeWin32Method();
Under what circumstances will I need to explicitly define the target attribute of method (say, to eliminate ambiguity) or is it just for the sake of completeness?
vcsjones
source share