IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesC++/CLIStatements  Print This     

Cross Ref > Statements

By Mike Prestwood

C++/CLI versus Delphi Prism: A side by side comparison between C++/CLI and Delphi Prism.

 
Statements
 

Common statements such as if statements, loops, etc.

Exception Trapping

[Other Languages] 

Languages Focus

A common usage of exception handling is to obtain and use resources in a "try-it" block, deal with any exceptions in an "exceptions" block, and release the resources in some kind of "final" block which executes whether or not any exceptions are trapped.

[Not specified yet. Coming...]
Delphi Prism:   try..except, try..finally

Use a try..except..end block to trap and process errors.

Delphi also offers a try...finally where code will execute in the finally section no matter what. It's common to put a try..except inside a try..finally.

Syntax Example:
try
  var y: Integer;
  y := 0;
  y := 1/y;
except
  MessageBox.Show("You cannot divide by zero.");
end;




If Statement

[Other Languages] 
C++/CLI:   if..else if..else

Same as standard C.

Syntax Example:
int x;
  
x = 8;
  
if (x == 10) {
MessageBox::Show("x is 10");
} else if (x < 10) {
MessageBox::Show("x is less than 10");
} else {
MessageBox::Show("x must be greater than 10");
}
Delphi Prism:   if..else if..else

Notice in the more complete example that the semicolon for the begin..end block after end is not included. That tells the compiler something else is coming (the statement is not finished). Also note the semicolon is missing right before the final "else" statement.

Syntax Example:
//Complete example:
if x = true then begin
  ShowMessage('x is true');
end
Else If y = 'Mike' Then 
  ShowMessage('hello mike')
Else 
  ShowMessage('last option');




Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]