1 / 21

Introduction to C#

Introduction to C#. By Sam Nasr Nasr Information Systems May 14, 2013. Agenda. Introduction What is .Net? .Net Framework Advantages of .Net/CLR Visual Studio C# Syntax. Introduction. Sam Nasr, MCAD, MCTS, MCT Software Developer since 1995 Nasr Information Systems

lynda
Download Presentation

Introduction to C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to C# By Sam NasrNasr Information Systems May 14, 2013

  2. Agenda • Introduction • What is .Net? • .Net Framework • Advantages of .Net/CLR • Visual Studio • C# Syntax

  3. Introduction • Sam Nasr, MCAD, MCTS, MCT • Software Developer since 1995 • Nasr Information Systems • President Cleveland C#/VB.Net User Group • President Cleveland WPF User Group • President .Net Study Group • INETA Mentor – Ohio • Author - Visual Studio Magazine

  4. What is .Net? • New programming methodology • Multiple Languages (VB.Net, C#, J#, etc.) • IL • JIT Compiler • Primary Parts: • .Net Framework • Common Language Runtime (CLR) - JIT Compiler • RTM: v4.5, since 2000

  5. .Net Framework • A set of approximately 3500 classes. • Classes are divided into namespaces grouping similar classes. • For organization, each class belongs to only one namespace. • Most classes are lumped into a name space called System • System.Data: DB access • System.XML: reading/writing XML • System.Windows.Forms: Forms manipulation • System.Net: network communication.

  6. .Net Framework • Supports Web Standards • HTML • XML • XSLT • SOAP • WSDL (Web Services) • ADO.Net: ActiveX Data Objects, EF • ASP.Net: Active Server Pages • Command Line Tools: ILDASM, ILASM, SN, etc.

  7. Advantages of .Net • Write once, run everywhere with .Net FW • Multiple programming languages (20+) • Coding Reduction • Controls • Template projects • IIS/Cassini support • Ease of Deployment • Security Features

  8. Visual Studio • IDE for development • Templates for: Console app, Web Service, Win Service, ASP.Net, Class Libraries • Security tools • VS Web Server (Cassini) • Application Testing • Team Suite for project management • Express versions (free)

  9. The C# Programming Language • Microsoft proprietary language • OO Language • High-level Language • Programs must be compiled before executed. • Case sensitive • Part of the .NET Framework, used for: • ASP.Net • Console Apps • WF • WCF • WPF • MVC

  10. Elements of a C# Program

  11. Structure of a C# Program

  12. The if-else Statement • The if-else statement allows your program to perform one action if the Boolean expression evaluates to true and a different action if the Boolean expression evaluates to false.

  13. Demo

  14. Exception Handling • An exception is an unexpected error condition that occurs during program execution. • When exception occurs, the runtime creates an exception object and “throws” it. • Unless you “catch” the exception, the program execution will terminate. • Exceptions are an object of the System.Exception class or one of its derived classes. • Example: DivideByZeroException exception object is thrown when the program attempts to divide by zero. • Example: FileNotFoundException exception object is throws when the program cannot find a given file.

  15. Unhandled Exceptions • What happens when the file c:\data.txt is not found in this code?

  16. Handling Exceptions • Place the code that throws the exceptions inside a try block. • Place the code that handles an exception inside a catch block. • You can have more than one catch blocks for each try block. Each catch block handles a specific exception type. • A try block must have at least a catch block or a finally block associated with it.

  17. Exception Handling Sample

  18. The finally Block • The finally block is used in association with the try block. • The finally block is always executed regardless of whether an exception is thrown. • The finally block is often used to write clean-up code.

  19. try-catch-finally Example

  20. Resources • C# Jumpstart Training: https://www.microsoftvirtualacademy.com/training-courses/developer-training-with-programming-in-c • Community Megaphone: http://www.communitymegaphone.com/ • C#/VB.Net Special Interest Group: http://www.ClevelandDotNet.info/ • Cleveland WPF User Group: http://www.clevelandwpf.info/ • .Net Study Group: http://www.meetup.com/net-study-Group/

  21. Contact Info sam@nasr.info http://ClevelandDotNet.blogspot.com @SamNasr http://www.linkedin.com/in/samsnasr Thank you for attending!

More Related