Sie sind auf Seite 1von 56

Language Fundamentals

VB.NET .NET Programming

Contents

VB.NET Source File Structure


VB.NET Keywords
Identifiers
Literals
Variables and Data Types
Variable Declaration and Initialization
Operators
Casting
Flow Controls

Objectives
At the end of this module, you should be able to:

Recognize and create properly constructed source code


Recognize and create properly constructed declarations
Distinguish between legal and illegal identifiers
Describe all value data types and their range
Recognize properly formatted data types
Declare and initialize variables
Understand the contents of the argument list of an applications Main()
method
Recognize and properly use operators
Identify object, shift and bitwise operators
Identify the order of evaluation and change its precedence
Cast primitive data types
Recognize the syntax and correct use of flow controls
Describe the concept of return statement
3

Agenda
Fundamentals
Operators
Flow Controls

VB.NET Source File Structure


Declaration order
1. Imports statement
Used to reference namespace.
When class names are to be referred in the
imports directive, aliases for the classes can
be used.
using alias-name = namespace.class-name

'
'
'
'

2. Namespace declaration

Namespace VBNETSchool
Public Class VBNetOne
''' <summary>
''' </summary>
''' <param name="args"></param>
Public Shared Sub Main(ByVal args As
String())
' print a message
A.WriteLine("Welcome to VB.NET!")
End Sub
End Class

Used to logically group similar classes that


have related functionality. In VB.NET you need
to declare each class in a namespace. By
default namespace is automatically created with
the same name as that of the project.
VBNETSchool is the namespace and
VBNETOne class is contained in the
namespace.
3. Class declaration
A VB.NET source file can have several
classes but only one class can have the Main
method

* Created on Feb 22, 2006


* First VB.NET Program

Imports System
Imports A = System.Console

End Namespace

VB.NET Source File Structure (Continued)


Comments
1. Single-line Comment

' insert

comments here

2. Documentation Comment
''' <summary>
''' </summary>
''' <param
name="args"></param>

Whitespaces
Tabs and spaces are ignored by
the compiler. They are used to
improve the readability of code.

'
'
'
'

* Created on Feb 22, 2006


* First VB.NET Program

Imports System
Imports A = System.Console
Namespace VBNETSchool
Public Class VBNetOne
''' <summary>
''' </summary>
''' <param name="args"></param>
Public Shared Sub Main(ByVal args As
String())
' print a message
A.WriteLine("Welcome to VB.NET!")
End Sub
End Class
End Namespace

VB.NET Source File Structure (Continued)


Class
Every VB.NET program
includes at least one class
definition. The class is the
fundamental component of all
VB.NET programs. Class is a
keyword
VBNetOne is a VB.NET
identifier that specifies the
name of the class to be
defined
A class definition contains all
the variables and methods
that make the program work.
This is contained in the class
body indicated by the opening
and closing braces.

'
'
'
'

* Created on Feb 22, 2006


* First VB.NET Program

Imports System
Imports A = System.Console
Namespace VBNETSchool
Public Class VBNetOne
''' <summary>
''' </summary>
''' <param name="args"></param>
Public Shared Sub Main(ByVal args As String())
' print a message
A.WriteLine("Welcome to VB.NET!")
End Sub
End Class

End Namespace

VB.NET Source File Structure (Continued)

Main() method
This line begins the Main()
method. This is the line at which
the program will begin executing.

ByVal args As
String()
Declares a parameter named
args, which is an array of string.
It represents command-line
arguments.

'
'
'
'

* Created on Feb 22, 2006


* First VB.NET Program

Imports System
Imports A = System.Console
Namespace VBNETSchool
Public Class VBNetOne
''' <summary>
''' </summary>
''' <param name="args"></param>
Public Shared Sub Main(ByVal args As String())
' print a message
A.WriteLine("Welcome to VB.NET!")
End Sub
End Class
End Namespace

VB.NET Source File Structure (Continued)

VB.NET
statement
A complete unit of work in a
VB.NET program.
A statement is always
terminated with a line break.
Except when the _ character is
used.

Console.WriteLine();
This line outputs the string
Welcome to VB.NET! followed
by a new line on the screen.

'
'
'
'

* Created on Feb 22, 2006


* First VB.NET Program

Imports System
Imports A = System.Console
Namespace VBNETSchool
Public Class VBNetOne
''' <summary>
''' </summary>
''' <param name="args"></param>
Public Shared Sub Main(ByVal args As String())
' print a message
A.WriteLine _
("Welcome to VB.NET!")
End Sub
End Class
End Namespace

VB.NET Keywords
Keywords are an essential part of language definition as they implement
specific features of the language.

AddHandler

AddressOf

Alias

And

As

Assembly

Auto

Boolean

ByRef

Byte

AndAlso

Ansi

ByVal

Call

Case

Catch

While

Unicode

CBool

CByte

CChar

CDate

With

Until

CDec

CDbl

Char

CInt

WithEvents

Variant

Class

CLng

CObj

Const

WriteOnly

When

CShort

CSng

CStr

CType

To

Sub

Date

Decimal

Declare

Default

True

SyncLock

Delegate

Dim

DirectCast

Do

Try

Then

Double

Each

Else

ElseIf

TypeOf

Throw
10

VB.NET Keywords
Event

Exit

False

Finally

Stop

Short

End

Enum

Erase

Error

Step

Shared

For

Friend

Function

Get

String

Single

GetType

GoSub

GoTo

Handles

Structure

Static

If

Implements

Imports

In

Return

ReDim

Inherits

Integer

Interface

Is

Select

REM

Let

Lib

Like

Long

Set

RemoveHandler

Loop

Me

Mod

Module

Shadows

Resume

MustInherit

MustOverride

MyBase

MyClass

Protected

ParamArray

Namespace

New

Next

Not

Public

Preserve

Nothing

NotInheritable

NotOverridable

Object

RaiseEvent

Private

On

Option

Optional

Or

ReadOnly

Property

OrElse

Overloads

Overridable

Overrides
11

Identifiers
An identifier is the name given by a programmer to a variable, statement
label, method, class, and interface.
An identifier must begin with a letter

Subsequent characters must be letters, digits or _ (underscore)


An identifier must not be a VB.NET keyword
Identifiers are case-insensitive
Keywords can be used as identifiers when they are enclosed in the [ ]
characters
Incorrect
Correct
3strikes
strikes3
Write&Print

Write_Print

printMe is the same as PrintMe


12

Literals
Literals are the way in which the values that are stored in variables are
represented.
VB.NET Literals

Numeric Literals

Integer Literals

Boolean Literals

Real Literals

Character Literals

Single character Literals

String Literals

13

Variable and Data Types


A variable is a named storage location used to represent data that
can be changed while the program is running.
A data type determines the values that a variable can contain and the
operations that can be performed on it.
Categories of data types include:
Value types
Reference types
pointers (used only in unsafe code)

14

Data Types
VB.NET Data Types

Value Types

Reference Types

Pointers

Predefined

User-defined

Predefined

User-defined

Types

Types

Types

Types

Integers

Enumerations

Objects

Classes

Real Integers

Structures

Strings

Arrays

Booleans

Delegates

Characters

Interfaces
15

Value Data Types


Predefined value types are also known as simple types (or primitive types).
SimpleTypes

Boolean Types

Numeric Types

Character Types

Floating Point

Integral

Decimal

Types

Types

Types

Signed

Unsigned

Types

Types
16

Data Types

Signed Integers

UnSigned Integers

sbyte

byte

short
int

long

ushort
uint

ulong

17

Value Data Types


FloatingPoint

Floatingpoint types

Types

Are used to hold numbers containing fractional parts.


There are two types:
float (single precision numbers)
double (double precision numbers)

float

double

Floatingpoint types support a special value known as Not-aNumber(NaN). NaN is used to represent results of operations such as
dividing zero by zero, where an actual number is not produced.

18

Value Data Types

(Continued)

Decimal Type

Is a high precision 128-byte data type that is designed for use in financial and
monetary calculations.
It can store values in the range 1.0 10e28 to 7.9 10e28.
To specify a number to be decimal type, append the character M (or m) to the
value e.g 123.45M.

Boolean Types

Are declared using the keyword, bool.


They have two values: true or false. In languages, such as C and C++, boolean
conditions can be satisfied where 0 means false and anything else means true.
In VB.NET the only values that satisfy a boolean condition is true and false,
which are official keywords.

Character Types

Are declared using the keyword char.


char type assumes a size of two bytes but can hold only a single character.
It is designed to hold a 16bit Unicode character.
19

Value Data Types

(Continued)

Structures

Syntax:

Are similar to classes.

member1 as data
member2 as data

End Structure

Are used for simple composite data types.


Structure keyword is used to declare
structures.
Variables are known as members or fields or
elements.
s1 is a variable type of structure Student.
Member variables can be accessed using dot
notation.

Structure struct-name

E.g..

Structure Student
Public Name As String
Public ID As Integer
Public TotalMark As Double
End Structure

Dim s1 as Student declare a student

s1.Name = John
S1.RollNumber = 0200789

20

Value Data Types

(continued)

Enumerations

Are a user-defined integer type which provides a way to attach names to


numbers.
Help increase comprehensibility of the code.
The enum keyword is used to define an enumeration.

A list of words in an enum is automatically assigned values of 0,1,2, etc.


The default value of the first enum member is set to 0 while each subsequent
member is incremented by one
Can be changed by assigning specific values to the members.

Syntax:

Enum enum-name
word1
word2
word3

End Enum

E.g.

Enum Color
Red = 10
Blue = 20
Green = 100
End Enum

21

Reference Data Types


Reference data types represent objects.
A reference serves as a handle to the object, it is a way to get to the
object.
VB.NET reference data types are divided into two types:
User-defined (or complex) types

Class
Interfaces
Delegates
Arrays

Predefined (or simple) types


Object type
String type

22

Variables
Default Values

Variables are either explicitly assigned a value or automatically assigned a


default value.

23

Constant Variables
Variables whose values do not change during execution of a program.

Use the Const keyword to initialize

Constants must be declared and initialized simultaneously

Constants can be initialized using an expression

Constants cannot use non-const values in an expression


Const age As Integer = 21
Const age As Integer
age = 21

Is illegal

Const m As Integer = 10
Const age As Integer = m * 5
Is illegal
Dim m As Itneger= 10
Const age as Integer = m * 5
24

Variable Declaration & Initialization


To declare a variable with value data type:

Dim age As Integer =


identifier primitive
type
name

21
initial
value

To declare a variable with reference data type:


Dim b1 As Box = new Box();
Dim name As String = Jason;
identifier
name

reference
type

initial
value

25

Value Type Declaration


declaration
Dim age As Integer
Identifier
name

MEMORY

allot space to memory

type
age

1
07

initialization/assignment

age =

17

Identifier value
name

stack

26

Reference Type Declaration


allot space to memory

Dim myCar As Car;

myCar

memory address
location

type

Identifier
name

reference
The heap

myCar = new Car(Bumble Bee);


Values

Identifier
name

Bumble Bee

Car object

27

Scope of Variable
..

Member Variables

Declared inside the class but


outside of all methods.
Accessible by all methods of
the class.

Public Class TestClass

Block2

Local Variables

Available only within the


method where they were
declared. Method parameters
have local scope.

Block1

Dim x as Integer =0
Public Sub TestSub
Dim n As Integer =5 Ok
Dim x As Integer =0 Ok
.
End Sub

Public Sub Sub2


n = n+1 wrong, n not available here

Block3

Dim m As Integer = 20 ok
x = m ok
End Sub
End Class

28

Boxing and UnBoxing


Boxing

Is a data type conversion technique that is used


implicitly to convert a value type to either an
object type or a reference type.

Public Shared Sub Main()


Dim x As Integer = 10
Dim obj1 As Object = x
x = 456
Console.WriteLine(x)

UnBoxing

Is the opposite of boxing. It is a data type


conversion technique that is used explicitly to
convert an object type to a value type.

Console.WriteLine(obj1)
End Sub

Public Shared Sub Main()


Dim x As Integer = 10
Dim obj1 As Object = x
Dim y As Integer = CType(obj1,
Integer)
Console.WriteLine(y)

End Sub

29

Agenda
Fundamentals
Operators
Flow Controls

30

Operators and Assignments

Unary operators
Arithmetic operators
String operators
Relational operators
Conditional operators
Logical operators
Assignment operators
Shift operators
Bitwise operators
Primitive Casting

31

Unary Operators
Unary operators use only one operand.
+

Positive sign

Negative sign

Sample code:
Dim num as Integer =10
System.Console.WriteLine("setting signs)
System.Console.WriteLine(+num)
System.Console.WriteLine(-num)

Sample output:
setting signs...
10
-10

32

Arithmetic Operators
Arithmetic operators are used for basic mathematical operations.
+

Add

Subtract

Multiply

Divide

Mod

Modulo, remainder

Sample code:
Dim num1 as Integer =15
Dim num2 as Integer =10
System.Console.WriteLine("calculating...")
System.Console.WriteLine(num1 + num2)
System.Console.WriteLine(num1 - num2)
System.Console.WriteLine(num1 * num2)
System.Console.WriteLine(num1 / num2)
System.Console.WriteLine(num1 Mod num2)

Sample output:
calculating...
25
5
150
1
5

33

String Operators
The string operator (+, &) is used to concatenate operands.
If one operand is string, the other operands are converted to string.

The & operand can also be used to concatenate strings.


Sample code:
Dim
Dim
Dim
Dim
Dim
Dim

fname As String = Henry


lname As String = Ford
mi As String = D"
fullName as String = lname + ", " + fname + " " + mi + "."
nickName As String = Henry"
age as Integer = 21

System.Console.WriteLine("My full name is: " + fullName)


System.Console.WriteLine("You can call me " + nickName + "!")
System.Console.WriteLine("I'm " + age + " years old.")

Sample output:
My full name is: Ford, Henry D.
You can call me Henry!
I'm 21 years old.
34

Relational Operators
Relational operators are used to compare values.
boolean values cannot be compared with non-boolean values.

Only object references are checked for equality, and not their states.
Objects cannot be compared with null.
null is not the same as .
<
<=
>
>=
=
<>

Less than
Less than or equal to
Greater than
Greater than or equal to
Equals
Not equals

35

Relational Operators
Sample code:
Dim name1 As String = "Marlon"
Dim weight1 As Integer = 140, height1 As Integer = 74
Dim name2 As String = "Katie"
Dim weight2 As Integer = 124, height2 As Integer = 78
Dim isLight As Boolean = weight1 < weight2, isLightEq As Boolean = weight1 <= weight2
System.Console.WriteLine("Is " + name1 + " lighter than " + name2 + "? " + isLight)
System.Console.WriteLine("Is " + name1 + " lighter or same weight as " + name2 + "? " +
isLightEq)
Dim isTall As Boolean = height1 > height2, isTallEq As Boolean = height1 >= height2
System.Console.WriteLine("Is " + name1 + " taller than " + name2 + "? " + isTall)
System.Console.WriteLine("Is " + name1 + " taller or same height as " + name2 + "? " +
isTallEq)
Dim isWeighEq As Boolean = weight1 = weight2, isTallNotEq As Boolean = height1 <> height2
System.Console.WriteLine("Is " + name1 + " same weight as " + name2 + "? " + isWeighEq)
System.Console.WriteLine("Is " + name1 + " not as tall as " + name2 + "? " + isTallNotEq)
System.Console.WriteLine("So who is heavier?")
System.Console.WriteLine("And who is taller?") Is Marlon lighter than Katie? false

Sample output:

Is Marlon lighter or same weight as Katie? false


Is Marlon taller than Katie? false
Is Marlon taller or same height as Katie? false
Is Marlon same weight as Katie? false
Is Marlon not as tall as Katie? true
So who is heavier?
And who is taller?
36

Logical Operators
Logical operators are used to compare
boolean expressions.
Not inverts a boolean value.
AND and OR evaluate both operands.

Truth Table
Op1

Op2

Not Op1

Op1 And
Op2

Op1 Or
Op2

false

false

true

false

false

false

true

true

false

true

true

false

false

false

true

true

true

false

true

true

Not

logical NOT

AND

logical AND

OR

logical OR

AndAlso

Same as And except


that once a false is
found it will not
continue checking the
succeeding
conditions.

OrElse

Same as Or except
that once a false is
found it will not
continue checking the
succeeding
conditions.

37

Logical Operators
Sample output:
Sample code:

Are you a candidate for promotion? true


Will you be promoted as a regular employee? false
Will you be promoted as a supervisor? false
Will you be promoted as a manager? true
Will you be paid more and work less? false
I hope you won't be demoted, are you? false

Dim yrsService As Integer = 8


Dim perfRate As Double = 86
Dim salary As Double = 23000
Dim position As Char = "S"C
' P-probationary R-regular, S-supervisor, M-manager, E-executive, T-top executive
Dim forRegular As Boolean, forSupervisor As Boolean, forManager As Boolean, forExecutive As
Boolean, forTopExecutive As Boolean
forRegular = yrsService > 1 And perfRate > 80 And position = "P"C And salary < 10000
forSupervisor = yrsService > 5 And perfRate > 85 And position = "R"C And salary < 15000
forManager = yrsService > 7 And perfRate > 85 And position = "S"C And salary < 25000
forExecutive = yrsService > 10 And perfRate > 80 And position = "M"C And salary < 50000
forTopExecutive = yrsService > 10 And perfRate > 80 And position = "E"C And salary < 75000
Dim isPromoted As Boolean = forRegular OrElse forSupervisor OrElse forManager OrElse
forExecutive OrElse forTopExecutive
Dim isLuckyGuy As Boolean = forExecutive Xor forTopExecutive
System.Console.WriteLine("Will you be promoted as a regular employee? " + forRegular)
System.Console.WriteLine("Are you a candidate for promotion? " + isPromoted)
System.Console.WriteLine("Will you be promoted as a supervisor? " + forSupervisor)
System.Console.WriteLine("Will you be promoted as a manager? " + forManager)
System.Console.WriteLine("Will you be paid more and work less? " + isLuckyGuy)
System.Console.WriteLine("I hope you won't be demoted, are you? " + Not isPromoted)
38

Assignment Operators
Assignment operators
are used to set the
value of a variable.
=

Assign

+=

Add and assign

-=

Subtract and assign

*=

Multiply and assign

/=

Divide and assign

&=

AND and assign

|=

OR and assign

^=

XOR and assign

Sample code:

Dim unitPrice As Double = 120, qty As Double = 2,


salesAmount As Double
Dim discRate As Double = 15, discAmount As Double,
vatRate As Double = 10, vatAmount As Double
' compute gross sales
salesAmount = unitPrice * qty
System.Console.WriteLine("Gross Sales: " + salesAmount)
' compute tax
vatRate /= 100
vatAmount = salesAmount * vatRate
salesAmount += vatAmount
System.Console.WriteLine("Tax: " + vatAmount)
' compute discount
discRate /= 100
discAmount = salesAmount * discRate
salesAmount -= discAmount
System.Console.WriteLine("Discount: " + discAmount)
System.Console.WriteLine("Please pay: " + salesAmount)

Sample output:
Gross Sales: 240.0
Tax: 24.0
Discount: 39.6
Please pay: 224.4

39

Casting (Type Conversion)


Casting is conversion from one data type to another which include:
Implicit casting
Explicit casting

Implicit Conversion is the conversion of one data type to another data


type without any loss of data.

40

Casting (Type Conversion)


Explicit Conversion is the conversion of one data type to another
data type with loss of data.

Explicit conversions can be carried out using the Ctype function.


Syntax:
Type variable1 =
Ctype(variable2,type);

E.g.. Dim amount As Single = 50


Dim totAmount As Long =
CType(amount, Long)
41

Summary of Operators
Evaluation order of operators in VB.NET is as follows:

Unary
Arithmetic
Comparison
Bitwise
Logical Operators
Assignment

42

Agenda
Fundamentals
Operators
Flow Controls

43

Flow Controls

If-Else statement
Select statement
While statement
Do-While statement
For statement
For Each statement
Exit statement
Continue statement

44

If-Else
If-Else performs
statements based on two
conditions.
Condition should result
to a boolean expression.

Syntax:

If condition is true, the


statements following if are
executed.
If condition is false, the
statements following else
are executed.
If-Else can be nested to
allow more conditions.

End If

If condition1 Then
ElseIf condition2 Then
Else

Dim age As Integer = 10


If age < 10 Then
System.Console.WriteLine("You're just a kid.")
ElseIf age < 20 Then
System.Console.WriteLine("You're a teenager.")
Else
System.Console.WriteLine("You're probably
old...")
End If

Output:
You're a teenager.

45

Select
Select performs
statements based on
multiple conditions.
exp can be char byte
short int, val should be
a unique constant of exp.
Case statements falls
through the next case
unless a exit is
encountered.
Case Else is executed if
none of the other cases
match the exp.

Syntax:
Select Case exp
Case val
'Do something
Case val
'do something
Case Else
'If no match it will pass here
End Select

Example:
Dim sex As Char = "M"
Select Case sex
Case "M"
System.Console.WriteLine("I'm a male.")
Case "F"
System.Console.WriteLine("I'm a
female.")
Case Else
System.Console.WriteLine("I am what I
am!")
End Select

Output:
I'm a male.

46

While
While performs statements repeatedly while condition remains true.
Syntax:

Example:

Output:

While condition
'Do something
End While
Dim ctr As Integer = 10
While ctr > 0
System.Console.WriteLine("Timer: " + ctr.ToString)
ctr -= 1
End While
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:

10
9
8
7
6
5
4
3
2
1
47

Do- Loop While


Do-While performs statements repeatedly (at least once) while
condition remains true.
Syntax:

Example:

Output:

Do
'this will run at least once
Loop While condition
Dim ctr As Integer = 0
Do
System.Console.WriteLine("Timer: " + ctr)
ctr += 1
Loop While ctr < 10
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:
Timer:

0
1
2
3
4
5
6
7
8
9
48

For Next
For enable us to execute
a series of expressions
multiple numbers of times

Syntax:
For init To final Step inc
'do something
Next

Example:
For age As Integer = 18 To 29
System.Console.WriteLine("Enjoy life while you're
" + age)
Next

Output:
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy
Enjoy

life
life
life
life
life
life
life
life
life
life
life
life

while
while
while
while
while
while
while
while
while
while
while
while

you're
you're
you're
you're
you're
you're
you're
you're
you're
you're
you're
you're

18
19
20
21
22
23
24
25
26
27
28
29
49

For Each
For Each() is similar to for statement
but implemented differently.
type and variable declare the
iteration variable. During execution,
the iteration variable represents the
array element (or collection element
in case of collections) for which an
iteration is currently being performed.
In is a keyword.
collection must be an array or
collection type and an explicit
conversion must exist from the
element type of the collection to the
type of the iteration variable.

Syntax:
For Each variable In collection
'Statement here
Next

Example:
Dim arrayint As Integer() = {11, 22,
33, 44}
For Each m As Integer In arrayint
System.Console.WriteLine(" " + m)
Next
System.Console.WriteLine()

Output:
11
22
33
44

50

Exit
Exit exits loops and other conditional statements.
Syntax:
Example:

Exit [conditonal operator]


Exit
Exit
Exit
Exit
Exit
Exit

For
Sub
Function
While
Do
Select

51

Continue

Continue is used inside loops to start a new iteration.


Same syntax as Exit
Syntax:
Example:

Output:

Continue [conditional operator];

For time As Integer = 7 To 11


If time < 10 Then
System.Console.WriteLine("Don't disturb! I'm studying...")
Continue For
End If
System.Console.WriteLine("zzzZZZ...")
Next

Don't disturb! I'm studying...


Don't disturb! I'm studying...
Don't disturb! I'm studying...
zzzZZZ...
zzzZZZ...

52

return
The return branching statement is used to exit from the current method.
There are two forms:
Example 1:
return <value>;
return;

Public Function sum(ByVal x As Integer, ByVal y As


Integer) As Integer
Return x + y
End Function
Example 2:
Public Function sum(ByVal x As Integer, ByVal y As
Integer) As Integer
x=x+y
If x < 100 Then
Return x
Else
Return x + 5
End If
End Function
Public Sub getSum(ByVal x As Integer)
System.Console.WriteLine(x)
Return
End Sub

53

Key Points
A VB.NET source file can include using, Namespace and class
declarations in that order
Identifiers are case-sensitive
VB.NET keywords cannot be used as identifiers
Each variable must be declared with a data type
There are 13 primitive data types: sbyte, short, int, long,
byte, ushort, uint, ulong, float, double, decimal,
char, boolean
There are 4 reference data types: classes, interfaces, delegates, and
arrays
Use unary, arithmetic operators for basic mathematical operations
Use string operator to concatenate strings

54

Key Points (Continued)


Use relational operators to compare objects
Use conditional operator as alternative to If- Else statement
Use logical operators to compare Boolean values

Use assignment operators to assign values to variables


VB.NET evaluates operators in order of precedence
Casting is converting one data type to another
If and Select are used for branching statements
While, Do While, For and For Each are used for iterating
statements
Exit, Continue are used to branch inside loops

55

Questions and Comments

56

Das könnte Ihnen auch gefallen