0
How i can create const variable
How can i do something like that: int x = 10; const int y = x; https://code.sololearn.com/c7lGVHMiSiYK/?ref=app
20 Respostas
+ 5
Just use "const int x = 10;" in the first line.
+ 5
Alternatively use "const int y = 10;" in the second line.
+ 2
Constants only accepts another constant or literal in initialization. Your <x> is non constant, that's why <y> is not getting initialized.
https://www.c-sharpcorner.com/UploadFile/2072a9/constant-vs-readonly-vs-static-keywords-in-C-Sharp/
+ 2
I have a method DllImport which take only const string variable, but first i need get this string. So I need something like a constant.
+ 2
I added link to example code
+ 2
Well, what did you expect? DLL are library files for Windows O/S.
You probably could try to run the code on Visual Studio under Windows.
+ 1
Share your code link in the original question Description (above) so the problem can be understood more obviously. At the moment anyone can only play guesses until your code is here for a review.
Follow this guide on sharing links in case you didn't know just yet
https://www.sololearn.com/post/74857/?ref=app
+ 1
Sorry, but it doesn't look like a valid way of dynamic linking to DLL (no DLL file was specified). Please check if that was really how it should be done, search for DllImport specifics on the net š
+ 1
Have a look at the link below.
https://stackoverflow.com/questions/8859060/c-sharp-using-const-with-dllimport
It seems you do not need to make it a const.
What happens if you use a regular string variable ?
+ 1
Dll on c++
+ 1
ok so I understand.
It is not about the calling a function in the dll.
It is about loading the dll in with DllImport.
Is it the path that is dynamic or the name of the .dll as well ?
Have a look at the link below.
https://stackoverflow.com/questions/8836093/how-can-i-specify-a-dllimport-path-at-runtime
or can you use
loadlibrary
https://dev.to/jeikabu/loading-native-libraries-in-c-fh6
0
DllImport is used to initialize a dll with unmanaged code, which is located in the project folder, to which you first need to know the path and then use it. I don't found another way to do this.
0
It's not what i need. I talk about it:
string x = "address";
[DllImport(x)] //Error: first argument must be a const variable
0
What is the language the dll was written in ?
0
Const variable - this is an oxymoron :)
0
It's don't work on android :/
0
Dll can be compiled for android, but now the main question is not, I need to somehow open this dll
0
Really, DLL can be compiled for Android?
Well good luck with trying
0
But why VS compiled dll file first, and then, compiling apk file?