0

I want to make something like the following pseudo-code work:

#define IMPORT = [DllImport ("MyDLL")] private static extern;

public class MyClass ... {
    IMPORT void my_function();
    ....
}

However, it would seem that #define works quite differently than in C/C++. Is there an equivalent for this in C#?

I know that #define will NOT work this way in C#, but if want to have the same functionality, how would it be done in C#? Are there any language features that allow for this?

aCuria
  • 6,935
  • 14
  • 53
  • 89
  • 1
    C# has no equivalent. It's preprocessor is much more limited compared to C/C++. –  Feb 02 '18 at 02:44
  • From the [C# Guide](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/) _Unlike C and C++ directives, you cannot use these directives to create macros._ You'd just have to spell it out https://stackoverflow.com/questions/709463/c-sharp-macro-definitions-in-preprocessor – Jasen Feb 02 '18 at 02:57

0 Answers0