DAD Lab. 1 Introduc7on to C#

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

Visual Studio.NET.NET Framework. Web Services Web Forms Windows Forms. Data and XML classes. Framework Base Classes. Common Language Runtime

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

Chapter 1 Getting Started

Introduction to C# Applications

.Net Technologies. Components of.net Framework

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

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

Understand Computer Storage and Data Types

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

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

PES INSTITUTE OF TECHNOLOGY

Introduction To C#.NET

NOIDATUT E Leaning Platform

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

Industrial Programming

Appendix G: Writing Managed C++ Code for the.net Framework

Language Specification

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

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

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

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

Question And Answer.

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

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

EEE-425 Programming Languages (2013) 1

Introduction to Java

A Comparison of Visual Basic.NET and C#

6.096 Introduction to C++ January (IAP) 2009

Used to write.net software Software that targets the.net Framework is called managed code

UNIT I An overview of Programming models Programmers Perspective

Assumptions. History

C# Fundamentals. built in data types. built in data types. C# is a strongly typed language

12/14/2016. Errors. Debugging and Error Handling. Run-Time Errors. Debugging in C# Debugging in C# (continued)

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

VISUAL PROGRAMMING_IT0309 Semester Number 05. G.Sujatha & R.Vijayalakshmi Assistant professor(o.g) SRM University, Kattankulathur

Modern Programming Languages. Lecture Java Programming Language. An Introduction

IT 528 Developing.NET Applications Using C# Gülşen Demiröz

Chapter 2: Using Data

Visual C# Instructor s Manual Table of Contents

DigiPen Institute of Technology

Programming refresher and intro to C programming

Java's Memory Management

Lecture 2, September 4

Pointers, Dynamic Data, and Reference Types

Chapter 6. Simple C# Programs

Bit (0, 1) Byte (8 bits: 0-255) Numeral systems. Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1/13/2011

Short Notes of CS201

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lec 3. Compilers, Debugging, Hello World, and Variables

The Microsoft.NET Framework

CS201 - Introduction to Programming Glossary By

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

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

Preview from Notesale.co.uk Page 9 of 108

Motivation was to facilitate development of systems software, especially OS development.

3. Basic Concepts. 3.1 Application Startup

CMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

II. Programming Technologies

C# Programming in the.net Framework

The plan. Racket will return! Lecture will not recount every single feature of Java. Final project will be wri)ng a Racket interpreter in Java.

Java and C CSE 351 Spring

Fall 2017 CISC124 9/16/2017

C # Language Specification

Introduction to Programming Using Java (98-388)

Motivation was to facilitate development of systems software, especially OS development.

Learn C# Errata. 3-9 The Nullable Types The Assignment Operators

Garbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; }

Principles of Computer Science

Overview. Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays. Initialization Searching

Module 3: Creating Objects in C#

Let s get started! You first need to download Visual Studio to edit, compile and run C# programs. Download the community version, its free.

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Introduction to Java

Lecture 1: Overview of Java

Object-Oriented Programming in C# (VS 2015)

What goes inside when you declare a variable?

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

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

CMSC 132: Object-Oriented Programming II. Inheritance

CS 376b Computer Vision

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

C++ Modern and Lucid C++ for Professional Programmers

377 Student Guide to C++

Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects

C# Frequently Asked Questions for C++ programmers

Multimedia-Programmierung Übung 3

Table of Contents Preface Bare Necessities... 17

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Game Engineering: 2D

Very similar to Java C++ C-Based syntax (if, while, ) object base class no pointers, object parameters are references All code in classes

Name of subject: JAVA PROGRAMMING Subject code: Semester: V ASSIGNMENT 1

C# Language Specification

OBJECT ORIENTED PROGRAMMING USING C++

CMSC 4023 Chapter 11

C# Java. C# Types Naming Conventions. Distribution and Integration Technologies. C# C++.NET A C# program is a collection of: C C++ C# Language

Distribution and Integration Technologies. C# Language

The Java Programming Language

Transcription:

DAD 2017-18 Lab. 1 Introduc7on to C#

Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons

1..NET Framework Introduc7on Architecture

.NET Framework Architecture

Common Language Run7me Execu7on Environment Memory Management Garbage collec7on Common type system Primi7ve types (int,double) Stack allocated Assignment copy values Freed at the block s end User- defined: struct, enum Classes, arrays,... Heap allocated Assignment copies reference Garbage collected

Framework Class Library System System.Collec7ons System.Drawing System.IO System.Data System.Windows.Forms System.Web.UI System.Web.Services...

.NET: Main Advantages Virtual execu7on environment. Many libraries. APIs for web development. Language interoperability. New standard: C#

C# 2.0 Basic Syntax: It s very similar to Java...

Hello World using System; public class HelloWorld { public static void Main(string[] args) { Console.WriteLine( Hello World! );

A simple Class public class Person { private string name; private int age; public Person(string name, int age) { this.name = name; this.age = age; public void ShowInfo() { Console.WriteLine( {0 is {1 years old., name, age); [...] Person client = new Person( John, 25); client.showinfo();

C#: Type System String string Name; Array int[] table; Object Class class Person {... Enum enum State { On, Off ValueType Struct struct Point { int x; int y; bool byte sbyte decimal char short ushort float int uint decimal account; double long ulong

C#: Everything Is an Object (2) int val = 10; object obj = val; int k = (int) obj; // k becomes 10 val 10 obj 10 System.Int32 Boxing k 10 Unboxing

Execu7on Control if, for, do, while, switch, foreach... switch without fall- through: switch a { case 2: x = 4; goto case 3 // explicit fall- through case 3:... Foreach: int[] table = {1, 2, 3; foreach (int i in table) Console.WriteLine( {0, i);

Classes Name hierarchy: namespaces Simple class inheritance. Mul7ple interface inheritance. Class members: Fields, methods, proper7es, indexers, events,.. Access levels: public, protected, internal, private Members can be static or instance. abstract members also possible.

C#: Inheritance public class Person { private string name; public class Employee : Person { private string company; public Person(string name) { this.name = name; public virtual void ShowInfo() { Console.WriteLine( Name:{0, name); public Employee(string name, int company) : base(name) { this.company = company; public override void ShowInfo() { base.showinfo(); Console.WriteLine( Company: {0, company); By default, methods are not virtual!

C#: Inheritance

C#: Parameter Passing ref passing value- types as references {... char c= c ; g(ref c); out passing non- ini7alized value- types as references: {... int x; f(out x); void g(ref char pc) { pc = x ; void f(out int x) { x=2;

C#: Parameter Passing params passing a variable number of parameters public static void Main() { UseParams(1, 'a', "test"); int[] myarray = new int[3] {10,11,12; UseParams(myarray); public static void UseParams(params object[] list) { for ( int i = 0 ; i < list.length ; i++ ) Console.WriteLine(list[i]); Console.WriteLine();

C#: Operator Redefini7on It is possible to redefine exis7ng operators. MyList A = new MyList(); MyList B = new MyList(); A.Add(1); A.Add(2); B.Add(3); B.Add(4); MyList C = A + B; // Joins both lists

C#: Operator Redefini7on (2) public class MyList { private object[] Elements;... MyList A = new MyList(); MyList B = new MyList ();... MyList C = A + B; public static MyList operator+(lista a, Lista b) { MyList result = new MyList (); // Copy the elements from <a> and <b> // into the return value return result;

C#: unsafe code Support for advanced programming, such as direct pointer manipula7on. Direct pointer and type manipula7ons must be performed within an unsafe block. int total = 0; unsafe { int* ptr = &total; *ptr = 10; public unsafe void FastCopy(byte* dst, byte* src, int count) { for (int i=0; i<count; i++) *dst++ = *src++;

C#: XML Documenta7on /// <summary> /// This method calculates a person s wages, /// based on the number of working days. /// </summary> /// /// <param name= workingdays"> /// The total of full working days. /// </param> /// /// <returns>the person s salary</returns> public int CalculateWages(int workingdays) {...

C# vs. C++ GC destroys unreachable objects. Reference types and value types. Boxing, unboxing. Method redefini7on must be explicit. Booleans are integers. switch without explicit fall- through. Unassigned variables cannot be used. (out) There are no global methods.

C# vs. Java Support for less than one and more than one class per file. Only one Main per assembly. Filename not related to contained classes. Namespaces instead of packages. goto Operator redefini7on. Unsafe code. Passing value- types by reference using ref. Output is an executable (.exe) or a library (.dll).

3. IDE: MS Visual Studio Tools Console / Win Form Applica7ons

IDE Development Environment.Net Framework 2.0 (minimum) Visual Studio.NET Tools Editor Compiler Debugger Projects Console applica7on Windows applica7on Class library ASP.Net web service ASP.Net web applica7on...