Common Language RuntimeWhich Language Should I Use?

   

Common Language Runtime Which Language Should I Use?

If you haven't decided on a language yet, I suggest that you consider either Visual Basic .NET or C#. These two languages seem to have emerged as the most popular languages in .NET circles and will provide you with the richest amount of support material in both reading and web resources.

I chose to include examples in the book in both Visual Basic .NET and C# because I think that these two languages cater to two different types of people. I've made several points about some general characteristics and attributes of both Visual Basic .NET and C# so far to try to help you decide. I guess I can sum it up this way:

Visual Basic .NET is a bit wordier but closer to regular English in its performance of form and function. (By the way, this is the language I generally use, but I'm also fond of C#).

C# is more compact, picky, and specific. It is a bit harder for the untrained eye to read, but as you become more accustomed to it you will habitually pay more attention to capitalization, line termination, and a few other of the common faux pas associated with the language.

I found myself rubbing my forehead and gouging my eyes while learning C# because I had become VERY, VERY!, VERY!! lazy about being careful during coding of ASP/VBscript applications when we built traditional ASP applications. VBScript is quite a forgiving language, but unfortunately I allow this liberty to reinforce bad coding practices that became painfully apparent when I learned C#. C# is not only unforgiving, it's brutal. But I've come to love it in its simplicity.

I know it sounds like I harp on C# more often than Visual Basic .NET, and if we went back and counted complaints or "Warnings" so far, this may be true. But this isn't because I think Visual Basic .NET is better than C#. It is just me communicating to another designer about the bumps I've hit in the road. I know that as a designer and conversely as an ASP/VBScript programmer, I was never very concerned about something like capitalization. C# is very concerned about capitalization, and if you choose to program in it you're going to need to be, too.

What I suggest is that if you haven't already decided which language you will use, read this chapter and see some of the different ways that common functions and controls are written in both Visual Basic .NET and C#. Then decide which one will best suit you.

I spend the rest of this chapter exploring the guts behind these two languages. You'll investigate variables and something called control structure and how these are handled in both languages.

Many of the code samples in this chapter require writing information to pages. In an effort to reinforce the Object/Event thing discussed in Chapter 1, I have made the following template page for you to use as a base for many of the examples in this chapter. Simply drop the blocks of code in the examples into the Page_Load() event (which has been highlighted in bold) and you should be good to go!!

Visual Basic .NET template_vb.aspx
<%@ page language="vb" runat="server"%>  <script  runat=server>  Sub Page_Load()      'Replace this with your code  End Sub  </script>  <html>  <title>VB.NET Template</title>  <body>  <asp:label  runat="server"/>  </body>  </html> 
C# template_cs.aspx
<%@ page language="c#" runat="server"%>  <script  runat=server>  public void page_load(){     //Replace with your code  }  </script>  <html>  <title>C# Template</title>  <body>  <asp:label  runat="server"/>  </body>  </html> 

   
Top


ASP. NET for Web Designers
ASP.NET for Web Designers
ISBN: 073571262X
EAN: 2147483647
Year: 2005
Pages: 94
Authors: Peter Ladka

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