Monday, March 30, 2015

Does C# support #define for defining global constants?

Question:Does C# support #define for defining global constants??

Answer: </P><P align=justify>No. If you want to get something that works like the following C code:</P><P align=justify>#define A 1</P><P align=justify>use the following C# code: class MyConstants</P><P align=justify>{</P><P align=justify>public const int A = 1;</P><P align=justify>}</P><P align=justify>Then you use MyConstants.A where you would otherwise use the A macro. </P><P align=justify>Using MyConstants.A has the same generated code as using the literal 1.

Tags:Interview Questions, Microsoft, C#,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement



School Administration Software

School Management System Software

This is One of the best School management system software in the world. School Software offers complete professional institute management system administration, library, accounting, inventory, etc for all the school activities management...

No comments:

Post a Comment