Designed by Anders Hejlsberg (creator of Turbo Pascal an PowerPoint PPT Presentation

presentation player overlay
1 / 22
About This Presentation
Transcript and Presenter's Notes

Title: Designed by Anders Hejlsberg (creator of Turbo Pascal an


1
Comparison ofC and VB.NetBySam NasrOctober
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 Microsofts
    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
  • 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 intCounter10
  • 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 intCounter0
  • 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 "ProviderMicrosoft.Jet.OLEDB.4.0"
  • cstr "Data Sourcec\\MyDB.mdb"
  • using (OleDBConnection conn new
    OleDBConnection(Cstr))
  • conn.open()

16
Documentation Comments (C)
  • ///ltsummarygt
  • ///A Sample Function to demonstrate C
  • ///lt/summarygt
  • ///ltparam namevoidgtThis function does not
    receive a parameter. lt/paramgt
  • ///ltreturnsgtVoid Typelt/returnsgt
  • 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
  • http//www.aspalliance.com/aldotnet/examples/trans
    late.aspx
  • http//www.kamalpatel.net/ConvertCSharp2VB.aspx
  • VB.Net to C
  • http//www.e-iceblue.com
  • http//www.vbconversions.com

20
Additional Information
  • C VB.NET Conversion Pocket Reference by Jose
    Mojica
  • C in a Nutshell By Peter Drayton, Ben Albahari,
    Ted Neward
  • http//en.wikipedia.org/wiki/Visual_Basic_programm
    ing_language

21
Upcoming Events
  • MSDN Event (http//msevents.microsoft.com)
  • Thursday (10/28/2004), 100 500 PM at Regal
    Town Cinemas. Free
  • New SQL Server SIG
  • Every 3rd Thursday 630-830 PM
  • ALG - 30640 Bainbridge Road in Solon
  • Next meeting COM and .Net Components
  • Thursday, Nov 23, 2004 630-830 PM

22
Career Info
  • Intuit Corp is seeking 2 Sr. .Net Developers.
    Contact Heather Winchester (heather_winchester_at_int
    uit.com) at 214-387-2125. See
    www.intuit.com/about_intuit/careers for more
    info.
  • Adaptive Solutions Group is seeking several C
    web developers for contract to hire. Contact
    Matt Twyman (mtwyman_at_adaptivesg.com) at
    314-236-3853. See www.adaptivesg.com for more
    info.
  • Robert Half Technology is accepting resumes for
    various development positions. Contact Kim
    Nasierowski (kimberly.nasierowski_at_rht.com) at
    216-621-6633. See www.rht.com for more info.
  • Tek Systems is accepting resumes for various
    development positions. Contact Janelle Capretta
    (jcapretta_at_teksystems.com) at 216-654-1840. See
    http//www.teksystems.com for more info.
  • Invesmart is seeking 2 VB.Net developer
    positions. See www.invesmart.com
Write a Comment
User Comments (0)
About PowerShow.com