Preprocessor directives in C#
By: Ram Baskar
C# features "preprocessor directives" (though it does not have an actual preprocessor) based on the C preprocessor that allow programmers to define symbols but not macros. Conditionals such as #if, #endif, and #else are also provided. Directives such as #region give hints to editors for code folding.
public class Foo
{
#region Procedures
public void IntBar(int firstParam) {}
public void StrBar(string firstParam) {}
public void BoolBar(bool firstParam) {}
#endregion
#region Constructors
public Foo() {}
public Foo(int firstParam) {}
#endregion
}
Archived Comments
1. I use this all the time. You can use this exactly like you've used C++ macros that can be controlled
View Tutorial By: Chetan at 2015-09-08 08:56:06
2. Really this is a good article, which helps a lot for beginners as me as well as developer. Check thi
View Tutorial By: Manoj Yadav at 2011-11-17 08:33:10
Most Viewed Articles (in Csharp ) |
Latest Articles (in Csharp) |
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview