A Brief Lexicon

Team Fly 

Page 21

A HANDY C# TO VE.NET TRANSLATORA

As you know, unfortunately some .NET Help and reference source code is written in C# (particularly online examples). However, C# is actually quite a simple language to understand and to translate into VB.NET. C# shares some of the backwards syntax of other C languages, and of course all those semicolons—but you can generally switch the C# source code lines around pretty quickly to get usable VB.NET code. However, if you don't want to bother, there's a handy translator that takes C# and generates the equivalent VB.NET. Find it at www.kamalpatel.net/ConvertCSharp2VB.aspx, and the utility is also available with full source code showing the process and the rules. If you prefer, though, you can just paste some C# and get the result automatically.

Choose Tools image WinCV and then type string in the Searching For box. You now see all the members of the string class, in a helpful quasi source code format. It's not VB, unfortunately; it's C#— but if you ignore the useless semicolons ending each line, and make a few other allowances (such as changing brackets to parentheses), it often provides a better overall view of a class's members than you get in Help. For example, the entry for the Split method looks like this:

 public string[] Split((char[] separator)); public string[] Split(char[] separator,, int count); 

You have to add the object for the method (String.), so after a little VB massaging it actually should look like this:

 String() = String.Split(char() separator) 

That's pretty descriptive pseudo-code. The WinCV is good for quick overviews of classes, their overloaded members, and correct syntax.

A Brief Lexicon

Given that C usage has permeated VB.NET, you might want to memorize the definitions and comparisons in Table 1.1. You'll come upon them now and then in the .NET documentation, and it helps to know what terms have shifted meaning. This small list supplements the other C-derived terms discussed at greater length throughout this chapter. Note that many of these term-pairs are still used interchangeably.

TABLE 1.1: VB VS. VB.NET TERMINOLOGY

TRADITIONAL VB USAGE

.NET

Private or Ppublic variables inside classes

Fields

DLL, library, or application

Assembly

Related DLLs, libraries, or applications

Namespace (imprecise in size: there can be multiple namespaces within a single assembly, or a single namespace can include several assemblies. Namespaces can even contain other namespaces.)

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net