Programmer's Corner Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programmer's Corner - Forums


ANSI C++ <-> C# <-> VB .NET

 
Post new topic   Reply to topic    Programmer's Corner Forum Index -> C# and VB.NET Reference
Author Message
DNAunion2000@
Ronin


Joined: 05 Jul 2003
Posts: 31

PostPosted: Sun Jul 06, 2003 10:00 am    Post subject: ANSI C++ <-> C# <-> VB .NET Reply with quote

DNAunion2000: I am moving from Visual FoxPro to .NET and am working on setting up a base command/concept conversion reference for myself (others might find it handy too). If anyone sees any errors please point them out.

ANSI C++, C#, and Visual Basic.NET Command Mappings

  Variable declaration/initialization (primitive data type):C++:     int nAge = 29;C#:     int nAge = 29;        VB:     Dim nAge As Integer = 29One-dimensional array declaration (primitive data type):C++:     int testScores[10] ;C#:     int[] testScores = new int[10] ;VB:' In VB you specify upper bound, not #of elements     Dim testScores(9) As Integer  Two-dimensional array declaration (primitive data type):C++:     int testScores[5][10] ;C#:     int[ , ] testScores = new int[5, 10] ;VB:     Dim testScores(4, 9) As IntegerConditional branching: if…then…elseC++:     if (x > 21)     {          // statements     }     else if (y < 50)     {          // statements     }     else     {          // statements     }C#:     if (x > 21)     {          // statements     }     else if (y < 50)     {          // statements     }     else     {          // statements     }VB:     If (x > 21) Then          ‘ statements     ElseIf (y < 50)          ‘ statements     Else          ‘statements     EndIf Conditional branching: switch/selectC++:     switch (userSelection)    {     case ‘C’:     case ‘c’:          cout << “You chose to Continue.”;          break;     case ‘Q’:     case ‘q’:          cout << “You chose to Quit.”;          break;     default:          cout << “Invalid selection…please try again.”;          break;     }C#:     switch (userSelection)     {     case ‘C’:     case ‘c’:          Console.WriteLine(“You chose to Continue.”);          break;     case ‘Q’:     case ‘q’:          Console.WriteLine(“You chose to Quit.”);          break;     default:          Console.WriteLine(“Invalid selection…please try again.”);          break;                             }VB: (can you use: Case "C" OR "c"?)     Select Case userSelection     Case “C”           Console.WriteLine(“You chose to Continue.”)     Case “c”          Console.WriteLine(“You chose to Continue.”)     Case “Q”          Console.WriteLine(“You chose to Quit.”)     Case “q”          Console.WriteLine(“You chose to Quit.”)     Case Else          Console.WriteLine(“Invalid selection…please try again.”)End SelectIteration: For loopC++:     for (int Lcv = 1; Lcv <= 10; Lcv++)     {          // statements     }C#:     for (int Lcv = 1; Lcv <= 10; Lcv++)     {          // statements     }VB:     For Lcv As Integer = 1 To 10 Step 1          ‘ statements     Next LcvIteration: While loopC++:     int Lcv = 1;     while (Lcv <= 10)     {          // statements          Lcv++;     }C#:     int Lcv = 1;     while (Lcv <= 10)     {          // statements          Lcv++;     }VB:     Dim Lcv As Integer = 1     While (Lcv <= 10)          ‘ statements          Lcv += 1     End 


removed emoticons

Edited by: *narf* at: 7/6/03 2:41 pm
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Programmer's Corner Forum Index -> C# and VB.NET Reference All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2002 phpBB Group