Introduce C# as Object Oriented programming language. Explain, tokens,

Similar documents
C#: framework overview and in-the-small features

.Net Technologies. Components of.net Framework

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

Introduction to C# Applications

Table of Contents Preface Bare Necessities... 17

This tutorial has been prepared for the beginners to help them understand basics of c# Programming.

Introduction to Programming Using Java (98-388)

Getting started 7. Storing values 21. Creating variables 22 Reading input 24 Employing arrays 26 Casting data types 28 Fixing constants 30 Summary 32

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Microsoft Visual C# Step by Step. John Sharp

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Prerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C#

Course Hours

Introduction To C#.NET

Object-Oriented Programming in C# (VS 2015)

C # Language Specification

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

Chapter 1 Getting Started

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Tokens, Expressions and Control Structures

Course Syllabus C # Course Title. Who should attend? Course Description

C# Programming in the.net Framework

C# and Java. C# and Java are both modern object-oriented languages

Object-Oriented Programming in C# (VS 2012)

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

Visual C# Instructor s Manual Table of Contents

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

Industrial Programming

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

C# MOCK TEST C# MOCK TEST I

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Programming in Visual Basic with Microsoft Visual Studio 2010

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

DAD Lab. 1 Introduc7on to C#

Introduction to C++ with content from

The C# Programming Language. Overview

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Computer Components. Software{ User Programs. Operating System. Hardware

Review of the C Programming Language for Principles of Operating Systems

Introduction to.net, C#, and Visual Studio. Part I. Administrivia. Administrivia. Course Structure. Final Project. Part II. What is.net?

5/23/2015. Core Java Syllabus. VikRam ShaRma

Question And Answer.

CPSC 3740 Programming Languages University of Lethbridge. Data Types

C++ (Non for C Programmer) (BT307) 40 Hours

Language Specification

Absolute C++ Walter Savitch

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Introducing C# and the.net Framework

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Short Notes of CS201

Duhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain

3. Java - Language Constructs I

Index COPYRIGHTED MATERIAL

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

CS201 - Introduction to Programming Glossary By

PES INSTITUTE OF TECHNOLOGY

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

A brief introduction to C programming for Java programmers

Programming in C# with Microsoft Visual Studio 2010

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

UNIT- 3 Introduction to C++

Introduction to Java

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Review of the C Programming Language

CMSC 330: Organization of Programming Languages

Chapter 6. Simple C# Programs

Decaf Language Reference Manual

C# Language Specification

6.096 Introduction to C++ January (IAP) 2009

1 Lexical Considerations

QUESTION BANK: INTRODUCTION TO PROGRAMMING (HCS102) a. Compare and contrast unboxing and widening using code snippets [10]

Lexical Considerations

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

CS 231 Data Structures and Algorithms, Fall 2016

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Modern Programming Languages. Lecture Java Programming Language. An Introduction

A Fast Review of C Essentials Part I

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Lexical Considerations

Program Fundamentals

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

ISO/IEC INTERNATIONAL STANDARD. Information technology Programming languages C# Technologies de l'information Langages de programmation C#

Chapter 2: Basic Elements of C++

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

A Comparison of Visual Basic.NET and C#

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

1 Shyam sir JAVA Notes

Variables. Data Types.

How to be a C# ninja in 10 easy steps. Benjamin Day

Chapter 2: Using Data

Type Conversion. and. Statements

MatchaScript: Language Reference Manual Programming Languages & Translators Spring 2017

VALLIAMMAI ENGINEERING COLLEGE

PROGRAMMING FUNDAMENTALS

Transcription:

Module 2 98

Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99

The C# Family Tree C Platform Independence C++ Object Orientation Java Platform Independence + Component Orientation VB Elegance C# Productivity 100

Introduction ti C# is intended to be a simple, modern, general-purpose, type-safe, object-oriented programming language. Its development team is led by Anders Hejlsberg. The most recent version is C# 4.0, which was released on April 12, 2010. 101

C# : The favourite programming language of.net Platform Paradigm Multi-Paradigm: Structured, Object-oriented, Event- Driven, Functional Appeared in 2001 Designed by Microsoft Developer Microsoft Stable release 4.0 (April 12, 2010) Influenced by Java, C++, Eiffel Platform Common Language Infrastructure License CLR Proprietary File extensions.cs Official Help C# Language (MSDN Microsoft Develpers Network) 102

The name "C Sharp" was inspired by musical notation where a sharp indicates that the written note should be made a half-step higher in pitch. This is similar to the language name of C++, where "++ indicates that a variable should be incremented by 1. Source: http://en.wikipedia.org/wiki/c_sharp_(programming_language) 103

VERSIONS of C# Language Version Date.NET Framework Visual Studio C# 1.0 C# 1.2 C# 2.0 C# 3.0 C# 4.0 January 2002.NET Framework 1.0 Visual Studio.NET 2002 Visual Studio April 2003.NET Framework 1.11.NET 2003 November 2005.NET Framework 2.0 November 2007.NET Framework 3.5 Visual Studio.NET 2005 Visual Studio.NET 2008 Visual Studio April 2010.NET Framework 4.0.NET 2010 104

Summary of Versions C# 2.0 C# 3.0 C# 4.0 C# 5.0 (planned) Features added 1. Generics 1. Implicitly typed 2. Partial types variables 3. Anonymous 2. Implicitly itl typed methods arrays 4. Iterators 3. Anonymous types 5. Nullable 4. Extension methods types 5. Query expressions 6. Lambda expressions 7. Expression trees 1. Dynamic binding 2. Named and optional arguments 3. Generic co- and contra variance 1. Asynchronou s methods 2. Compiler As a Service 105

C# : A Curtain Raiser. C# is a modern language. g It supports the notion of data types, flow of control statements, operators, arrays, properties, and exceptions. C# is an object-oriented language. It supports classes and the object-oriented nature of classes including encapsulation, inheritance, and polymorphism. C# also supports interfaces in conjunction with the.net Common Language g Runtime (CLR) garbage g collection, which some feel is necessary in an object-oriented language. It also supports the notion of indexers, which in simplified terms lets you manipulate objects as arrays and delegates. 106

C# Versus Java Both new-generation languages g Both provide automatic garbage collection, reducing low-level maintenance tasks from the programmer Syntactically almost similar Concept of intermediate language common C# supports more primitive data types than Java, and also allows more extension to the value types like enumerations & structures. C# permits operator overloading Like Java, C# does not support multiple implementation inheritance A class cannot be derived from more than one class However, a class can be derived from multiple interfaces. C# uses delegates type-safe method pointers to implement event handling. In addition to jagged arrays, C# also implements genuine rectangular array, as against Java, where multidimensional arrays are implemented solely with single-dimensional array. 107

C# Versus C++ Closest relative, than java & vb. No need of header files. All code inline..net runtime provides memory management activities like garbage collection, importance of pointer nullifies. C# types are ultimately derived from the object type. Automatic array bounds checking. Fall through behavior of C++ Switch statement is disallowed in C#. C# gives upon the idea of multiple inheritance. Support for class properties of the kind found in VB Class methods are called using the. Operator rather than the :: operator. 108

Features of C# Simplicity Consistent type behavior supported by a unified type system Automatic garbage collection Error handling features Modern debugging features Robust security features Pure OOPL, everything is an object. Type safety. Automatic bound-check for collections. Versioning support interoperable 109

Boxing and unboxing Boxing is the operation of converting a value of a value type into a value of a corresponding reference type.boxing in C# is implicit. Unboxing is the operation of converting a value of a reference type (previously boxed) into a value of a value type.unboxing in C# requires an explicit type cast. A boxed object of type T can only be unboxed to a T (or a nullable T). Example: int foo = 42; // Value type. object bar = foo; // foo is boxed to bar. int foo2 = (int)bar; // Unboxed back to value type. On the stack i On the heap 123 On the stack i On the heap int i = 123; o (i boxed) int int i = 123; o Object o = i; int 123 Object o = i; j 123 int j = (int) o; 123 110

Tokens token examples identifiers Hiker Main result keywords public class int literals 9 6 13 operators + - * / % = punctuators ; { }, 111

Identifiers Rules answer42 42Answer different Different made of letters and digits must start with a letter underscore is a letter case sensitive No other special character other than underscore. The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style. 112

Valid identifiers _minute total Sum4 Hello67_hello @class _ 34343 113

Invalid Identifiers &total Minute# 4hour @12hello (strongly discouraged) abc@abc Sum terms $asdfa 114

Keywords abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using virtual void while get set value add remove These are sometimes reserved Verbatim: Any keyword can be used as an identifier if preceded by @ 115

Data Types C# is a type-safe language. Variables are declared as being of a particular type, and each variable is constrained to hold only values of its declared type. Value types [Stack] Primitives int i; Enum enum state {off, on} Struct struct point { int x; float y;} Nullable Types Reference types [Heap] Predefined d Reference Types Object String User-defined Reference Types Classes Interfaces Delegates Arrays 116

A Value-Type variable directly contains an object with some value. No other variable can directly contain the object contained. Reference type variable directly contains is something which refers to an object. Another variable can contain a reference to the same object referred to by the original variable. Reference types actually hold the value of a memory address occupied by the object they reference. Class Demo { Class XYZ { Public int myvalue; } Public static void Main() { XYZ X = newxyz(); X.myValue = 10; XYZ Z = X; Z.myValue = 20; // after this statement both X.myValue and Z.myValue equals 20. } } 117

Literals truth type bool literal true false floating point integers double 3.1415 int 9 6 13 42 characters sequences of characters char string 'X' "Hello" nothing object null 118

Operators symbol category + - * / % arithmetic ==!= equality < <= > >= relational &&! logical = assignment & ^ ~ << >> bitwisei 119

Punctuators t some tokens that group or separate { and } form scoped blocks semi-colons mark the end of a simple statement using System; public class Hiker { public static void Main() { int result; result = 9 * 6; int tirteen; tirteen = 13; Console.Write(result / tirteen); Console.Write(result % tirteen); } } 120