Top Banner
By Sam Nasr Nasr Information Systems May 14, 2013
21

By Sam Nasr Nasr Information Systems May 14, 2013.

Dec 16, 2015

Download

Documents

Delilah Goodwin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: By Sam Nasr Nasr Information Systems May 14, 2013.

By Sam Nasr

Nasr Information Systems

May 14, 2013

Page 2: By Sam Nasr Nasr Information Systems May 14, 2013.

AgendaIntroductionWhat is .Net?.Net FrameworkAdvantages of .Net/CLR Visual StudioC# Syntax

Page 3: By Sam Nasr Nasr Information Systems May 14, 2013.

IntroductionSam Nasr, MCAD, MCTS, MCTSoftware Developer since 1995Nasr Information SystemsPresident Cleveland C#/VB.Net User GroupPresident Cleveland WPF User GroupPresident .Net Study GroupINETA Mentor – OhioAuthor - Visual Studio Magazine

Page 4: By Sam Nasr Nasr Information Systems May 14, 2013.

What is .Net? New programming methodology

Multiple Languages (VB.Net, C#, J#, etc.) IL JIT Compiler

Primary Parts:1. .Net Framework2. Common Language Runtime (CLR)

- JIT Compiler

RTM: v4.5, since 2000

Page 5: By Sam Nasr Nasr Information Systems May 14, 2013.

.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.

Page 6: By Sam Nasr Nasr Information Systems May 14, 2013.

.Net FrameworkSupports Web Standards

HTMLXMLXSLTSOAPWSDL (Web Services)

ADO.Net: ActiveX Data Objects, EF

ASP.Net: Active Server Pages

Command Line Tools: ILDASM, ILASM, SN, etc.

Page 7: By Sam Nasr Nasr Information Systems May 14, 2013.

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

Page 8: By Sam Nasr Nasr Information Systems May 14, 2013.

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)

Page 9: By Sam Nasr Nasr Information Systems May 14, 2013.

The C# Programming LanguageMicrosoft proprietary languageOO LanguageHigh-level LanguagePrograms must be compiled before executed.Case sensitivePart of the .NET Framework, used for:

ASP.Net Console Apps WF WCF WPF MVC

Page 10: By Sam Nasr Nasr Information Systems May 14, 2013.

Elements of a C# Program

Data Types Types of data in a program. Common data types are int (integers), char (single character value), float (floating point values).

Variables Provides temporary storage during program execution.int number = 10;

Constants Data fields whose value cannot be modified.const int i = 10;

Arrays A collection of items in which each item can be accessed by a unique index.int[] numbers = { 1, 2, 3, 4, 5 };

Operators Symbols that specify which operation to perform on operands before returning a result.

Methods Methods are code blocks containing a series of statements. Methods can receive input via arguments and can return a value to the caller.

Page 11: By Sam Nasr Nasr Information Systems May 14, 2013.

Structure of a C# Program

Page 12: By Sam Nasr Nasr Information Systems May 14, 2013.

The if-else StatementThe 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.

Page 13: By Sam Nasr Nasr Information Systems May 14, 2013.

Demo

Page 14: By Sam Nasr Nasr Information Systems May 14, 2013.

Exception HandlingAn 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.

Page 15: By Sam Nasr Nasr Information Systems May 14, 2013.

Unhandled ExceptionsWhat happens when the file c:\data.txt is not

found in this code?

Page 16: By Sam Nasr Nasr Information Systems May 14, 2013.

Handling ExceptionsPlace 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.

Page 17: By Sam Nasr Nasr Information Systems May 14, 2013.

Exception Handling Sample

Page 18: By Sam Nasr Nasr Information Systems May 14, 2013.

The finally BlockThe 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.

Page 19: By Sam Nasr Nasr Information Systems May 14, 2013.

try-catch-finally Example

Page 20: By Sam Nasr Nasr Information Systems May 14, 2013.

ResourcesC# 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/

Page 21: By Sam Nasr Nasr Information Systems May 14, 2013.

Contact [email protected]

http://ClevelandDotNet.blogspot.com

@SamNasr

http://www.linkedin.com/in/samsnasr

Thank you for attending!