+ 25

Does C# has #define like C++?

Sometimes C# is long and I wanna shorten it using #define

10th Sep 2018, 11:26 PM
ShortCode
14 Respuestas
+ 17
C# has #define but it's not the same as C/C++. In C/C++, we use #define for constants, but in C# this directive is used as a flag. https://code.sololearn.com/cFO3wKCOtZ1x/?ref=app
11th Sep 2018, 12:45 AM
dim_knp
dim_knp - avatar
+ 10
Unfortunately nope and we seldom use #define in C#. If you wish to write shorter and cleaner code, you may consider extension methods or delegates. 😉
11th Sep 2018, 12:18 AM
Zephyr Koo
Zephyr Koo - avatar
+ 6
c# has define and is very long but c++ is very easy and short
11th Sep 2018, 1:12 PM
MJARAB
MJARAB - avatar
+ 5
When you are creating C# codes to solve easy problems, I think you should include only necessary "using directives" 😊😊
11th Sep 2018, 1:26 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 1
A very one Hello
12th Sep 2018, 1:32 PM
Len Kor
Len Kor - avatar
+ 1
Hello)
13th Sep 2018, 3:49 AM
Len Kor
Len Kor - avatar
+ 1
No, C# does not support preprocessor macros like C. Visual Studio on the other hand has snippets. Visual Studio's snippets are a feature of the IDE and are expanded in the editor rather than replaced in the code on compilation by a preprocessor
13th Sep 2018, 1:33 PM
deepak sharma
deepak sharma - avatar
0
hello
12th Sep 2018, 6:13 PM
Ajax
Ajax - avatar
0
I'm bad speaking to inglish language (
13th Sep 2018, 3:50 AM
Len Kor
Len Kor - avatar
0
but I want learn this language
13th Sep 2018, 3:51 AM
Len Kor
Len Kor - avatar
0
yes
13th Sep 2018, 7:26 AM
Danny
0
Are you national russian ?
13th Sep 2018, 11:45 AM
Len Kor
Len Kor - avatar
0
ок, я тоже из россии
15th Sep 2018, 5:09 AM
Len Kor
Len Kor - avatar
0
???
27th Sep 2018, 6:29 PM
Len Kor
Len Kor - avatar