Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comparison of C# and VB.Net By Sam Nasr October 26, 2004

Similar presentations


Presentation on theme: "Comparison of C# and VB.Net By Sam Nasr October 26, 2004"— Presentation transcript:

1 Comparison of C# and VB.Net By Sam Nasr October 26, 2004

2 What is C#? C# (C-Sharp) is a new language developed by Microsoft Corporation. Designed by Anders Hejlsberg (creator of Turbo Pascal and architect of Delphi), Scott Wiltamuth, and Peter Golde. Described as a “...simple, modern, object-oriented, and type-safe programming language derived from C and C++”. Bears many syntactic similarities to C++ and Java.

3 What is VB.Net? VB.Net is the latest release of Microsoft’s Visual Basic language. VB is an event driven programming language. Derived heavily from BASIC. VB enables Rapid Application Development (RAD) of graphical user interface (GUI) applications.

4 Myths VB.Net is intended for use with Microsoft Office.
C# is the latest release of C++. C# is easier to learn than VB.Net. To better understand C#, one should first learn C++. A .Net solution can contain only 1 language.

5 Language Differences Syntax Object Oriented Features
The differences of the 2 languages lie in: Syntax Object Oriented Features Visual Studio.Net IDE

6 Syntax Differences Case Sensitivity Line Termination Comments
Namespace Declaration and Usage Variable Declaration Variable Initialization Declaring Function Parameters Passing Function Parameters Optional Parameters Parameter Lists Method Declaration Returning Output Parameters Program Startup Exiting Programs/Methods/Loops Member Scope Static/Shared Methods Classes versus Modules If statements Short Circuiting Conditional Statements Properties and Indexers Arrays For Loops For/Each Loops Try/Catch Blocks Attribute Usage Control Characters Type Comparison and Conversion

7 C# Example (Syntax) /* C Style comment */ // C++ Style comment
///Enhanced comment for Documentation Feature Void SampleProc() { int intCounter1=0; MessageBox.show(“Counter1=” + intCounter1.ToString()); } //end of SampleProc

8 VB.Net Example (Syntax)
‘Style of comments for VB.Net Sub SampleProc() Dim intCounter1 as Integer, intCounter2 as Integer MessageBox.show(“Counter1=” & intCounter1) End Sub ‘end of SampleProc

9 Object-Oriented Features
Inheritance Syntax Method Overloading Constructors Invoking Other Constructors Invoking Base Constructors Initializers Hiding Base Class Members Overriding methods Requiring/Preventing Inheritance Declaring and Implementing Interfaces Delegated and Events Comparing Classes String Comparisons

10 C# Example (Object Oriented)
class App { static void Main(string [ ] args) int intCounter=0; foreach (string arg in args) System.Console.WriteLine(“Counter:” + intCounter.ToString() + “=“ + arg); } //end of foreach } //end of Main() } //end of App{}

11 VB.Net Example (Object Oriented)
Class App Shared Sub Main(ByVal args as String( ) ) Dim arg as String Dim intCounter as Integer For Each arg in args System.Console.Writeline(“Counter: ” & intCounter & “=“ & arg) Next ‘For Each loop End Sub ‘end of Main() End Class ‘end of App{}

12 IDE Differences AssemblyInfo.x Default/Root Namespace Startup object
App.ico Imports/Using COM References Compiler Constants Options: (Explicit, Strict, Compare) Errors and Warnings

13 Specific Language Features
Unsafe Blocks (C#) Using (C#) Documentation Comments (C#) Operator Overloading (C#) Late Binding (VB)

14 Unsafe Blocks (C#) class Class1 {
static unsafe void main (string[ ] args) string sName = “Joe Mojica”; fixed (char *Temp = sName) char *ch= Temp; ch +=4; *ch = (char)o; ch += 1; *ch = (char) o; } System.Console.WriteLine(sName);

15 Using (C#) void OpenDatabase() { string cstr;
cstr = "Provider=Microsoft.Jet.OLEDB.4.0"; cstr += "Data Source=c:\\MyDB.mdb;"; using (OleDBConnection conn = new OleDBConnection(Cstr)) conn.open(); }

16 Documentation Comments (C#)
///<summary> ///A Sample Function to demonstrate C# ///</summary> ///<param name=“void”>This function does not receive a parameter. </param> ///<returns>Void Type</returns> Void SampleProc() { int intCounter1, intCounter2; MessageBox.show(“Counter1=” & intCounter1); } //end of SampleProc

17 Controversial Issues Point C# offers less typing.
C# is a better programming language because it forces variables to be defined. C# code runs faster. Counter-Point VB.Net offers automatic case setting VB.Net offers Option Explicit Speed is debatable!

18 Which Language do I choose for my organization?
Which language features do I need? Which language features can I live without? What is the background of the staff? Which language does my staff work more comfortably with? Can staff members be comfortable with both? What is the availability of Human Resources for a specific language?

19 Language Converters C# to VB.NET VB.Net to C#
VB.Net to C#

20 Additional Information
C# & VB.NET Conversion Pocket Reference by Jose Mojica C# in a Nutshell By Peter Drayton, Ben Albahari, Ted Neward

21 Upcoming Events MSDN Event (http://msevents.microsoft.com)
Thursday (10/28/2004), 1:00 – 5:00 PM at Regal Town Cinemas. Free New SQL Server SIG Every 3rd Thursday 6:30-8:30 PM ALG Bainbridge Road in Solon Next meeting: COM and .Net Components Thursday, Nov 23, :30-8:30 PM

22 Career Info Intuit Corp is seeking 2 Sr. .Net Developers. Contact Heather Winchester at See for more info. Adaptive Solutions Group is seeking several C# web developers for contract to hire. Contact Matt Twyman at See for more info. Robert Half Technology is accepting resumes for various development positions. Contact Kim Nasierowski at See for more info. Tek Systems is accepting resumes for various development positions. Contact Janelle Capretta at See for more info. Invesmart is seeking 2 VB.Net developer positions. See


Download ppt "Comparison of C# and VB.Net By Sam Nasr October 26, 2004"

Similar presentations


Ads by Google