Skip to Content
Programming .NET Security
book

Programming .NET Security

by Adam Freeman, Allen Jones
June 2003
Intermediate to advanced
714 pages
22h 8m
English
O'Reilly Media, Inc.
Content preview from Programming .NET Security

Chapter 22. Converting from C# to VB Syntax

Although API Quick Refererence information on all types and their members is shown using C# syntax, it is easy to mentally convert these entries to Visual Basic syntax. This chapter will provide the information you need to convert the C# documentation for each type into the syntax used by Visual Basic .NET programmers.

Tip

This chapter doesn’t try to completely cover the syntax for each language element it discusses. Instead, it focuses on direct translation of the syntax of the types used in programming from C# to VB.

General Considerations

The most evident difference between C# and VB syntax is that C# uses the semicolon (;) as a statement terminator, whereas VB uses a line break. As a result, a statement in C# can occupy multiple lines as long as it is terminated with a semicolon; a VB statement must occupy only a single line. Multiline statements in VB must appear with the VB line-continuation character (a space followed by an underscore) on all but the last line.

A second, and not quite so evident, difference is that C# is case-sensitive, whereas VB isn’t. (Uniform casing for VB code is enforced by the Visual Studio environment, but it is by no means required.)

Finally, all types and their members have access modifiers that determine the type or member’s accessibility. The keywords for these access modifiers are nearly identical in VB and C#, as Table 22-1 shows.

Table 22-1. Access modifiers in C# and VB

C# keyword

VB keyword

public ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

.NET Framework Security

.NET Framework Security

Brian A. LaMacchia, Sebastian Lange, Matthew Lyons, Rudi Martin, Kevin T. Price
.NET Security and Cryptography

.NET Security and Cryptography

Peter Thorsteinson, G. Gnana Arun Ganesh
ASP.NET Core Security

ASP.NET Core Security

Christian Wenz

Publisher Resources

ISBN: 0596004427Supplemental ContentErrata Page