.NET
•  Greatis •  Security •  AppDatabase •  Utilities •  Delphi/CB • Visual Basic •  just4fun
.NET Software
.NET Components for Visual Studio .NET, Delphi 8, Delphi 2005 and Delphi 2006
 .NET     Entire site
More Info
Delphi to C#
Index

.NET
Form Designer .NET

See also
Delphi VCL software
Visual Basic 6 software
Hot Offer

Form Desigber .Net

Delphi to C#
Language
Conditional compilation

  Delphi  

       In the code conditional symbols work like boolean expressions - each of them can be defined or undefined:
{$IFDEF SPECIAL}
// code here will be compiled if the SPECIAL is defined
{$ELSE}
// code here will be compiled if the SPECIAL is undefined
{$ENDIF}
$ELSE is optional, so you can writel something like this:
{$IFDEF SPECIAL}
// code here will be compiled if the SPECIAL is defined
{$ENDIF}
You can also use $IFNDEF directive to compile code when some symbol is ubdefined:
{$IFNDEF SPECIAL}
// code here will be compiled if the SPECIAL is undefined
{$ENDIF}
The symbol can be defined in the Conditional Defines of project options, or in the code directly:
{$DEFINE SPECIAL}
{$UNDEF SPECIAL}
Conditional symbols can be used for including/excluding some debug code, for creating special versions, etc. If the TRIAL will be defined, the functionality of the following code will be truncated:
procedure TMyForm.SaveToFile(FileName: string);
begin
  {$IFDEF TRIAL}
  ShowMessage('Data cannot be saved in this trial version');
  {$ELSE}
  DataContainer.SaveToFile(FileName);
  {$ENDIF}
end;
Delphi predefines several useful symbols, depended from the compiler version (for instance, Delphi 7 defines VER150), from the operation system (MSWINDOWS or LINUX), from the application type (CONSOLE for console applications), etc.
 
 
  C#

In C# this feature is called preprocessor directives. The following pre-processing directives are available. #define and #undef, which are used to define and undefine, respectively, conditional compilation symbols. #if, #elif, #else, and #endif, which are used to conditionally skip sections of source code. #line, which is used to control line numbers emitted for errors and warnings. #error and #warning, which are used to issue errors and warnings, respectively. #region and #endregion, which are used to explicitly mark sections of source code.

#define, #undef, #if, #else and #endif accords to Delphi's $DEFINE, $UNDEF, $IDEF, #ELSE and $ENDIF. C# has new feature, which simplyfies nested if else if else conditions: #elif = else if.

#if Enterprise
  // enterprise options
#elif Professional
  // professional options
#else
  // standard options
#endif

Lost features     
Added features New #elif condition.
Warnings
Additional information

 
 


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2009 Greatis Software

eXTReMe Tracker