
472
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 22C# to VB Syntax
22
Converting from C# to
VB Syntax
Although information on all types and their members is shown using C# syntax,
it is easy to mentally convert to Visual Basic syntax. This chapter will provide the
information you need to convert the documentation for each type into the syntax
used by Visual Basic.
This chapter does not aim at providing complete coverage of the
syntax for each language element it discusses. Instead, it focuses on
direct translation of the syntax of the types used in ASP.NET pro-
gramming from C# to VB.
General Considerations
The most evident difference between C# and VB syntax is that C# uses the semi-
colon (;) as a statement terminator, whereas VB uses a line break. Hence, while a
statement in C# can occupy multiple lines as long as it is terminated with a semi-
colon, a VB statement must occupy a single line. Multiline statements in VB must
appear with the VB line continuation character (a space followed by an under-
score) on all but the last line.
A second, and not quite so evident, difference is that C# is case-sensitive, whereas
VB is not. (Uniform casing for VB code is enforced by the Visual Studio environ-
ment, but it is by no means required.)
Finally, all types and their members have access modifiers that determine the type
or member’s ...