在C#中是否可以这样定义一个变量,并在声明中将其赋值,例如:
#define myVariable "MyFile.dll"
...
[DllImport(myVariable, CharSet = CharSet.Unicode)]
public static extern string someFunction(string directory);
?
答案 0 :(得分:3)
您可以声明一个常量,然后在属性规范中使用它:
const { constants } = require('crypto')
https.createServer({
secureOptions: constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1
pfx: fs.readFileSync(path.resolve(pathToCert))
}, app).listen(443)
这就是您要查找的文件名。您也可以在其他类型中使用它,例如
public const string LibraryDll = "MyFile.dll";
[DllImport(LibraryDll, CharSet = CharSet.Unicode)]
public static extern string someFunction(string directory);