Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Comparison of C# and VB.Net October 26, 2004 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. 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. 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++. 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. Bears many syntactic similarities to C++ and Java.

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

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

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

6 Syntax Differences Case Sensitivity Case Sensitivity Line Termination Line Termination Comments Comments Namespace Declaration and Usage Namespace Declaration and Usage Variable Declaration Variable Declaration Variable Initialization Variable Initialization Declaring Function Parameters Declaring Function Parameters Passing Function Parameters Passing Function Parameters Optional Parameters Optional Parameters Parameter Lists Parameter Lists Method Declaration Method Declaration Returning Output Parameters Returning Output Parameters Program Startup Program Startup Exiting Programs/Methods/Loops 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; int intCounter1=0; MessageBox.show(Counter1= + intCounter1.ToString()); MessageBox.show(Counter1= + intCounter1.ToString()); } //end of SampleProc } //end of SampleProc

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

9 Object-Oriented Features Inheritance Syntax Inheritance Syntax Method Overloading Method Overloading Constructors Constructors Invoking Other Constructors Invoking Other Constructors Invoking Base Constructors Invoking Base Constructors Initializers Initializers Hiding Base Class Members 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) static void Main(string [ ] args) { int intCounter=0; int intCounter=0; foreach (string arg in args) foreach (string arg in args) { System.Console.WriteLine(Counter: + intCounter.ToString() + = + arg); System.Console.WriteLine(Counter: + intCounter.ToString() + = + arg); } //end of foreach } //end of foreach } //end of Main() } //end of Main() } //end of App{}

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

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

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

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

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

16 Documentation Comments (C#) ///

///A Sample Function to demonstrate C# /// /// This function does not receive a parameter. /// This function does not receive a parameter. /// Void Type /// Void Type Void SampleProc() { int intCounter1, intCounter2; int intCounter1, intCounter2; MessageBox.show(Counter1= & intCounter1); MessageBox.show(Counter1= & intCounter1); } //end of SampleProc

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

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

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

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

21 Upcoming Events MSDN Event (http://msevents.microsoft.com) MSDN Event (http://msevents.microsoft.com)http://msevents.microsoft.com Thursday (10/28/2004), 1:00 – 5:00 PM at Regal Town Cinemas. Free New SQL Server SIG New SQL Server SIG Every 3 rd Thursday 6:30-8:30 PM ALG Bainbridge Road in Solon Next meeting: COM and.Net Components Next meeting: COM and.Net Components Thursday, Nov 23, :30-8:30 PM 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. 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. 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. 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. 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 Invesmart is seeking 2 VB.Net developer positions. See


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

Similar presentations


Ads by Google