×
Namespaces

Variants
Actions
Revision as of 01:23, 16 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Qt Vs C sharp Vs Visual Basic的基础知识

From Nokia Developer Wiki
Jump to: navigation, search
WP Metro Icon Porting.png
SignpostIcon WP7 70px.png
Article Metadata

兼容于
文章
翻译:
最后由 hamishwillee 在 16 Jul 2013 编辑

Contents

简介

Nokia在宣布和微软一起研发Windows Phone后,为开发者群提供了另一个Windows Phone平台。经过这次公告后,虽然Nokia的开发者群体明显变大了,但Nokia同时也要求Qt开发人员学习全新的Windows Phone平台。这篇文章的理念是非常基础的,我将非常高兴如果能有积极的开发人员和Wiki用户为这篇文章补充更多的内容。这篇文章描述了Qt, C# (读作C Sharp) 和 Visual Basic在编程语言方面的差异。C# 和Visual Basic是Windows Phone开发支持的两种语言。Qt 和 C#都是从C++中派生出的,所以它们的基本语法非常相似。


注解

Visual Basic

  'This line is commented

C#

// This line is commented 
 
/* This line block is
 
Commented */

Qt

与C#相似 
 
// This line is commented
/* This line block is
Commented */

数据类型

Visual Basic

Boolean

Byte, SByte

Char

Short, UShort, Integer, UInteger, Long, ULong

Single, Double

Decimal

C#

bool, 
byte, sbyte
char
short, ushort, int, uint, long, ulong
float, double
decimal

Qt

bool, 
char,
short,
int,
long,
float,
double

变量声明

Visual Basic

Dim <variable name> as <datatype> = [<default Value>]

for example

Dim TotalAmount as long=123456

C#

<datatype> <variable name> = [<default value>] 
// example
long Totalamount = 123456

Qt

<datatype> <variable name> = [<default value>] 
// Example
long Totalamount = 123456

If….ElseIf…EndIf

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.. Case结构

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;
}

循环

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
}


Try....Catch

Visual Basic

Try

    'do something
catch ex As Exception
    'do something

End Try

C#

try 
{
// do something
}
catch (Exception ex)
{
//do something
}

Qt

try 
{
// do something
}
catch (e)
{
//do something
}
This page was last modified on 16 July 2013, at 01:23.
99 page views in the last 30 days.
×