cwm9
cwm9

Reputation: 773

Why does DllImport require an Identifier?

I'm a little confused.

In the code:

[DllImport("library.dll")]
public static extern void function(int x);

why is the x required? Shouldn't the int be enough as this is just a definition and not a declaration?

Upvotes: 1

Views: 178

Answers (1)

Habib
Habib

Reputation: 223187

Its the C# Syntax, the same goes for methods in interface.

Probably the biggest reason is, that it adds clarity to the code. Parameter name may tells about the expected value in method

Upvotes: 3

Related Questions