Introduction to .Net and C#

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Advertisements

Introduction to .NET Framework
BY BOWYA G.  This International Standard is based on a submission from Hewlett-Packard, Intel, and Microsoft, that describes a language called C#. 
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
.Net Overview Giuseppe Attardi Università di Pisa.
Overview of the.NET Framework. What is the.NET Framework A new computing platform designed to simplify application development A consistent object-oriented.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Introduction to the C# Programming Language for the VB Programmer.
History  We first begin with Java which was released in 1995 by Sun Microsystems  Initially Java was 100% interpreted at runtime and was very slow 
C#/.NET Jacob Lewallen. C# vs.NET.NET is a platform. Many languages compile to.NET: –VB.NET –Python.NET –Managed C++ –C#
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Intro to C# Language Richard Della Tezra IS 373. What Is C#? C# is type-safe object-oriented language Enables developers to build a variety of secure.
DotNET A Developer’s Perspective Mike Litzkow University of Wisconsin - MadisonOne.
Introduction to.NET. What is.NET? Microsoft’s vision of the future of applications in the Internet age –Increased robustness over classic Windows apps.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Rajeswari Indupuri Introduction to.NET Framework.
OOP Languages: Java vs C++
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
Programming Languages and Paradigms Object-Oriented Programming.
Introduction to .Net Framework
.Net Training Lecture – 1 Author: Suhrid Patel. What is.NET ? It is a platform neutral framework. Is a layer between the operating system and the programming.
VS.NET Syllabus By Peter Huang.
Module 1: Introduction to C# Module 2: Variables and Data Types
.NET & C# Introduction 11 March, 2004 Yusung Kim CS441 Introduction to Computer Networking.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a library for.
Introduction to .NET Rui Ye.
 Internet providing backbone for applications  Use of several web sites and devices to provide one complete solution  Software as services  Quick software.
Compiling and Executing Code in.Net Microsoft Intermediate Language and Common Language Runtime.
.NET Framework Overview
Introduction .NET Framework
ISYS 573 Special Topic – VB.Net David Chao. The History of VB Early 1960s:BASIC-Beginner’s All-Purpose Symbolic Instruction Code –Teaching –Simple syntax,
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
.NET Language Supports. .NET Language Support Operating System Common Language Runtime Base Class Library ADO.NET and XML ASP.NET Web Forms Web Services.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Introduction to Computers and Programming.
Component-Based Software Engineering Introduction to.NET Paul Krause.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
Microsoft.NET Object Oriented Software Engineering Course Presentation Murat Can Ganiz 04/01/2004.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Application Foundation Presented By : Naveed Sattar Software Engineer.
1 C# A brief overview by Jack Senechal and Bryan Powell.
Rajiv and Shipra Introduction to.NET (asp.net,c#,vb)
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Introduction to.NET. What is.NET? Microsoft’s vision of the future of applications in the Internet age –Increased robustness over classic Windows apps.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company.NET Basic Fundamentals Presented By : Muhammad Atif Hussain Deputy Manager.
Intro to dot Net Dr. John Abraham UTPA CSCI 3327.
Key Components of.NET Framework  Common Language Runtime  CLR at Design time  CLR at Runtime  Class Library  Assemblies  Namespaces  ASP.NET  Applications.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Object Oriented Software Development 4. C# data types, objects and references.
Introduction to C# By: Abir Ghattas Michel Barakat.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to the Microsoft.NET Framework Chris Wastchak Student Ambassador to Microsoft.
Introduction to .NET Framework
CS360 Windows Programming
Introduction to C# AKEEL AHMED.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Presentation transcript:

Introduction to .Net and C# BIT-7

Agenda Features of .Net Framework .NET vs. J2EE .Net Framework C# features and design goals C# basics Unified type system Enum Arrays

Features of .Net Framework Interoperability with other environments Need of plateform independent applications (windows, Unix ) Microsoft Intermediate Language (MSIL) Set of CPU independent instruction Unix compiler complies MSIL code to one that UNIX understand. Support for developing language independent applications Common development environment for all languages So code can be shared among application developed in diff. languages Support for OOPs Support for Web applications Support for Web services

.NET vs. J2EE Both are similar in many ways: J2 Enterprise Edition Server- and client-side model for building enterprise applications. Virtual machine designed to inspect, load, and execute programs in a controlled environment. APIs for creating both fat- and thin-client models. APIs for foundation services (data access, directory, remote object calls, sockets, forms). Development environment for dynamic web pages. J2 Enterprise Edition Language-Dependent & Platform-Independent .NET Language-Independent & Platform Dependent (for now)

J2EE: Language-Specific, Platform- Independent Person.java Linux Java VM Java VM Person bytecodes Deploy Windows Company bytecodes Java VM Address bytecodes Solaris Address.java Company.java Java VM

.NET: Language-Independent, (Mostly) Platform- Specific Person.vb Windows (Visual Basic) CLR CLR Person MSIL Deploy Windows Company MSIL CLR Address MSIL Others? Address.cs (C#) Company.cbl CLR (Cobol)

.NET Framework C# VB.NET C++.NET Other Visual Studio .NET Common Language Specification Framework Class Library ASP.NET Windows Forms Web Services Web Forms Controls Drawing ASP.NET Application Services Windows Application Services ADO.NET XML Threading IO Network Security Diagnostics Etc. Common Language Runtime Memory Management Common Type System Lifecycle Monitoring Operating System

Common Language Runtime A runtime provides services to executing programs Standard C library, MFC, VB Runtime, JVM CLR provided by .NET manages the execution of code and provides useful services Memory management, type system, etc. Manage threads and helps in security Managed vs. unmanaged code

.NET Framework Class Library Framework – you can call it and it can call you Large class library Over 2500 classes Major components Base Class: Networking, security, I/O, files, etc. Data and XML Classes Web Services/UI Windows UI

Common Language Specification CLS is a set of rules that specifies features that all languages should support Goal: have the .NET framework support multiple languages CLS is an agreement among language designers and class library designers about the features and usage conventions that can be relied upon

Some .NET Languages C# Perl COBOL Smalltalk Eiffel VB.NET Fortran Mercury Pascal Python Perl Smalltalk VB.NET VC++.NET J#.NET …. More are planned or under development

C# Features Design Goals of C# New OO programming language C# is advanced version of C and C++ and Specially designed for .NET environment Strong versioning support Unified type system / type safety Automatic memory management Designed to leverage the CLR Design Goals of C# Component-orientation Everything is an object Robust and durable software Preserving your investment First of all, C# was designed from the ground up to support components concepts like events, methods and properties. Second, everything is an object, which allows us to create some really clean designs. Third, it was designed to make it easy to create robust and maintainable software And finally, it should be able to integrate easily with everything that already exists, preserving your investment.

C# Basics Variables Modifiers <modifiers> <datatype> <variable1, variable2………..> Modifiers Internal Private Protected Public Read only Static

C # basics : Types of variables There are seven types of variables in c# Static Instance Array elements {stores starting address of an array in memory} Value parameter {without ref or out modifier} Reference parameters {with ref modifier} Out parameters {with ref modifier} Local variables Variable Scope Block Procedure Namespace

Out parameter using System; class Test { static void Divide(int a, int b, out int result, out int remainder) { result = a / b; remainder = a % b; } static void Main() { for (int i = 1; i < 10; i++) for (int j = 1; j < 10; j++) { int ans, r; Divide(i, j, out ans, out r); Console.WriteLine("{0} / {1} = {2}r{3}", i, j, ans, r);

C # Basics : Unified Type System Value types Directly contain data Cannot be null Reference types Contain references to objects May be null 123 i s "Hello world" int i = 123; string s = "Hello world";

C # Basic :Unified Type System Value (Struct) Reference (Class) Variable holds Actual value Memory location Allocated Stack Heap Nullability Always has value May be null Default value null Aliasing No Yes = means Copy value Copy reference Can inherit from Actually, structs are aliased when passed through “ref” parameters, as discussed later. Even still, only one alias can be in scope at a time.

Unified Type System Everything is an object All types ultimately inherit from object Any piece of data can be stored, transported, and manipulated with no extra work Everything inherits from object, including primitive types, structs or classes.

Unified Type System Polymorphism The ability to use or store an object without knowing its precise type void Poly(object o) { Console.WriteLine(o.ToString()); } The example shows a function, Poly(), that is called with different types of arguments. Poly(42); Poly(“abcd”); Poly(12.345678901234m); Poly(new Point(23,45));

Unified Type System Boxing copies a value type into a reference type Unboxing copies it out i 123 int i = 123; object o = i; int j = (int)o; o System.Int32 Line 2 illustrates boxing. Line 3 illustrates unboxing. 123 j 123

Unified Type System Unboxing Inverse operation of boxing Copies the value out of the box Copies from reference type to value type Requires an explicit conversion May not succeed

Boxing and Unboxing Example using System; struct Struct1 { Public int Value; } class Class1 public int Value = 0; class Test static void Main() { Struct1 val1 = new Struct1(); Struct1 val2 = val1; val2.Value = 123; Class1 ref1 = new Class1(); Class1 ref2 = ref1; ref2.Value = 123; Console.WriteLine("Values: {0}, {1}", val1.Value, val2.Value); Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value); Values: 0, 123 Refs: 123, 123 Boxing and Unboxing Example

Unified Type System Benefits Lots of examples in .NET Framework Enables polymorphism across all types Collection classes work with all types Eliminates need for wrapper classes Lots of examples in .NET Framework Main benefits of the Unified Type System: No need of wrapper code to use base types in collections or arrays No Variants anymore Hashtable t = new Hashtable(); t.Add(0, "zero"); t.Add(1, "one"); t.Add(2, "two"); string s = string.Format( "Your total was {0} on {1}", total, date);

Predefined Types Integral Types C# Type System Type Size (bytes) Signed? sbyte System.Sbyte 1 Yes short System.Int16 2 int System.Int32 4 long System.Int64 8 byte System.Byte No ushort System.UInt16 uint System.UInt32 ulong System.UInt64 C# Type System Type Size (bytes) float System.Single 4 double System.Double 8

Statements Ecma : C# language specifications Page 29

Operators Is Sizeof Typeof Int i=10; If(i is object) { …………….} { …………….} Sizeof sizeof(int); Typeof typeof(string);

Types User-defined Types Enumerations enum Arrays int[], string[] Interface interface Reference type class Value type struct Function pointer delegate

User defined Types :Enums enum Color { Red, Blue, Green } class Shape public void Fill(Color color) { switch(color) { case Color.Red: . break; case Color.Blue:

User defined Types : Arrays Arrays allow a group of elements of a specific type to be stored in a contiguous block of memory Arrays are reference types Derived from System.Array Zero-based Can be multidimensional Arrays know their length(s) and rank Provide bounds checking

User defined Types : Arrays Declare Allocate Initialize Access and assign Enumerate int[ ] primes; int[ ] primes = new int[9]; int[ ] prime = new int[ ] {1,2,3,5,7,11,13,17,19}; int[ ] prime = {1,2,3,5,7,11,13,17,19}; prime2[i] = prime[i]; foreach (int i in prime) Console.WriteLine(i);

Single-dimensional arrays using System; class Test { static void Main() { int[] arr = new int[5]; for (int i = 0; i < arr.Length; i++) arr[i] = i * i; Console.WriteLine("arr[{0}] = {1}", i, arr[i]); }

User defined Types : Arrays Multidimensional arrays Rectangular int[,] matR = new int[2,3]; Can initialize declaratively int[,] matR = new int[2,3] { {1,2,3}, {4,5,6} }; Jagged An array of arrays int[][] matJ = new int[2][]; Must initialize procedurally

User defined Types : Arrays class Test { static void Main() { int[] a1; // single-dimensional array of int int[,] a2; // 2-dimensional array of int int[,,] a3; // 3-dimensional array of int int[][] j2; // "jagged" array: array of (array of int) int[][][] j3; // array of (array of (array of int)) }

User defined Types : Arrays class Test { static void Main() { int[] a1 = new int[] {1, 2, 3}; int[,] a2 = new int[,] {{1, 2, 3}, {4, 5, 6}}; int[,,] a3 = new int[10, 20, 30]; int[][] j2 = new int[3][]; j2[0] = new int[] {1, 2, 3}; j2[1] = new int[] {1, 2, 3, 4, 5, 6}; j2[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; }

Parameter array A parameter array enables a many-to-one relationship: many arguments can be represented by a single parameter array. In other words, parameter arrays enable variable length argument lists. class Test { static void F(params int[] args) { Console.WriteLine("# of arguments: {0}", args.Length); for (int i = 0; i < args.Length; i++) Console.WriteLine("\targs[{0}] = {1}", i, args[i]); } static void Main() { F(); F(1); F(1, 2); F(1, 2, 3); }}

THANK YOU!