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?

2
  • 1
    C# has no equivalent. It's preprocessor is much more limited compared to C/C++. Commented Feb 2, 2018 at 2:44
  • From the C# Guide Unlike C and C++ directives, you cannot use these directives to create macros. You'd just have to spell it out stackoverflow.com/questions/709463/… Commented Feb 2, 2018 at 2:57

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.