Comparing Qt C++, C-Sharp and Visual Basic
This article provides a comparative overview of programming languages used on Nokia Platforms: C# and Visual Basic (Windows Phone), and Qt C++(Symbian and MeeGo).
Article Metadata
Article
Created: girishpadia
(15 Oct 2011)
Updated: girishpadia
(15 Oct 2011)
Last edited: hamishwillee
(30 Nov 2012)
Contents |
Comments
Visual Basic
'This line is commentedC#
// This line is commented
/* This line block is
Commented */
Qt C++ (same as for C#)
// This line is commented
/* This line block is
commented */
Data Types
Visual Basic
C#
bool
byte, sbyte
char
short, ushort, int, uint, long, ulong
float, double
decimal
Qt
bool
char
short
int
long
float
double
Variale declarations
Visual Basic
C#
<datatype> <variable name> = [<default value>]
// example
long Totalamount = 123456
Qt
<datatype> <variable name> = [<default value>]
// Example
long Totalamount = 123456
Condition statements
Visual Basic
IF <expression> THEN
'Do something
ELSEIF <expression> THEN
'Do something
ELSE
'Do something
END IF
C#
if (<expression>)
{
// do something if expression is true
}
elseif(<expression>)
{
// do something if expression is true
}
else
{
// do something if expression is false
}
Qt
if (<expression>)
{
// do something if expression is true
}
else if(<expression>)
{
// do something if expression is true
}
else
{
// do something if expression is false
}
Switch
Visual Basic
SELECT CASE <data>
CASE <value1>
'Do something
CASE <value2>
'Do something
CASE ELSE
'Do something if non of above case matched
END SELECT
C#
switch (data)
{
case <value1>:
//Do something
break;
case <value2>:
//do something
break;
default:
//do something if non of obove case matched.
break;
}
Qt
switch (data)
{
case <value1>:
//Do something
break;
case <value2>:
//do something
break;
default:
//do something if non of obove case matched.
break;
}
Loops
Visual Basic
WHILE <expression>
'do something
END WHILE
DO WHILE <expression>
'do something
LOOP
DO UNTIL <expression>
'do something
LOOP
FOR <variable>=<startValue> TO <endValue> STEP <increments>
'do something
NEXT
C#
while (<expression>)
{
// do something
}
do
{
// do something
}while(expression);
for(<variable>=<startValue>;<expression>;<increment>)
{
// do something
}
Qt
while (<expression>)
{
// do something
}
for(<variable>=<startValue>;<expression>;<increment>)
{
// do something
}
Exception handling
Visual Basic
C#
try
{
// do something
}
catch (Exception ex)
{
//do something
}
Qt
try
{
// do something
}
catch (e)
{
//do something
}


Hamishwillee - Not sure how useful this is
Hi Girish
I've added some links to other comparative articles in a SeeAlso. I think that these are more likely to be useful than this article itself because they are a lot more complete. In addition they cover the essential differences and similarities in the language "philosophy", which I find most useful when starting to learn a new language. I'd also suggest that Qt developers are going to find VB a relatively unlikely new language to learn, so concentrating on just Qt and C#might be more useful.
Anyway, something to think about.
Regards
Hamishhamishwillee 07:02, 20 February 2012 (EET)