C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.

Slides:



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

2. C# Language Fundamentals
Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
Execute Blocks of Code Multiple Times Svetlin Nakov Telerik Corporation
Execute Blocks of Code Multiple Times Telerik Software Academy C# Fundamentals – Part 1.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
Getting Started with C# 1 SWE 344 Internet Protocols & Client Server Programming.
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
Dale/Weems/Headington
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
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 
3. Data Types. 2 Microsoft Objectives “.NET is designed around the CTS, or Common Type System. The CTS is what allows assemblies, written in different.
Programming in C# Language Overview
Introduction to Classes and Objects (Through Ch 5) Dr. John P. Abraham Professor UTPA.
.NET Data types. Introduction ٭ A "data type" is a class that is primarily used just to hold data. ٭ This is different from most other classes since they're.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall
Programming Language C++ Xulong Peng CSC415 Programming Languages.
C#C# Introduction CS3260 Dennis A. Fairclough Version 1.0 Introduction CS3260 Dennis A. Fairclough Version 1.0.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
ITF11006.NET The Basics. Data Types – Value Types – Reference Types Flow Control – Conditional – Loop Miscellaneous – Enumerations – Namespaces Class.
C Sharp Web & Internet Programming Group Diana, Aren, Jeff, & Adam, Farrin 5/5/20081CS 311.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
CIS 3301 C# Lesson 3 Control Statements - Selection.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 8 th Lecture Pavel Ježek
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CSC 298 Streams and files.
1.2 Primitive Data Types and Variables
Chapter One Lesson Three DATA TYPES ©
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
Computer Programs CS 1400 Dennis A. Fairclough Version 1.1 CS 1400 Dennis A. Fairclough Version 1.1.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Quick Summary C++/CLI Basics Data Types Controls Arrays In-class assignments.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
Object Oriented Programming Lecture 2: BallWorld.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Information and Computer Sciences University of Hawaii, Manoa
Basic Introduction to C#
C# — Console Application
Data types Data types Basic types
Understand Computer Storage and Data Types
Computing with C# and the .NET Framework
Chapter 3: Understanding C# Language Fundamentals
Reserved Words.
Chapter 2.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I UTPA – Fall 2012 This set of slides is revised from lecture slides.
null, true, and false are also reserved.
Conditional Statements
Introduction to Java Programming
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Data Types Imran Rashid CTO at ManiWeber Technologies.
The important features of OOP related to C#:
Module 2 Variables, Assignment, and Data Types
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
Welcome back to Software Development!
Module 2 Variables, Data Types and Arithmetic
C Language B. DHIVYA 17PCA140 II MCA.
Presentation transcript:

C# Language Report By Trevor Adams

Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect Anders Hejlsberg Anders Hejlsberg C# 1.0 – mid 2000 C# 1.0 – mid 2000 C# 2.0 – 2005 C# 2.0 – 2005 C# 3.0 – Currently Under Development C# 3.0 – Currently Under Development

Implementation Hybrid Implementation Hybrid Implementation.Net Framework.Net Framework Preprocessor Preprocessor Unsafe Code Unsafe Code

Overall Structure of a Program // A skeleton of a C# program using System; namespace MyNamespace1 { class MyClass1 class MyClass1 { } struct MyStruct struct MyStruct { } interface IMyInterface interface IMyInterface { } delegate int MyDelegate(); delegate int MyDelegate(); enum MyEnum enum MyEnum { } namespace MyNamespace2 namespace MyNamespace2 { } class MyClass2 class MyClass2 { public static void Main(string[] args) public static void Main(string[] args) { } }}

Control Structures Selection Statements Selection Statements Iterative Statements Iterative Statements Unconditional Branching Unconditional Branching

Selection Statements selection-statement=> if-statement |switch-statement if (x == y) { //execute block if true} else { //execute block if false} string myString = "hello"; switch (myString) { case "hello": Console.WriteLine("Hello there"); break; case "goodbye": Console.WriteLine(“Good Bye Dude"); break; }

Iterative Statements iteration-statement => while-statement | do-statement | for-statement | foreach-statement using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace ConApp.Demo { class Program { class Program { static void Main(string[] args) { static void Main(string[] args) { ArrayList arrList = new ArrayList(); ArrayList arrList = new ArrayList(); arrList.Add("First Item"); arrList.Add("First Item"); arrList.Add("Second Item"); arrList.Add("Second Item"); arrList.Add("Third Item"); arrList.Add("Third Item"); foreach(string myString in arrList){ foreach(string myString in arrList){ Console.WriteLine(myString); Console.WriteLine(myString); } Console.ReadLine(); Console.ReadLine(); } }}

Unconditional Branching jump-statement => break-statement | continue-statement | goto-statement | return-statement | throw-statement

Data Types Primitive Data Types Primitive Data Types Arrays Arrays Record Types Record Types Union Types Union Types Pointer Types Pointer Types

Primitive Data Types object - The ultimate base type of all other types object - The ultimate base type of all other types string - String type; a string is a sequence of Unicode characters string - String type; a string is a sequence of Unicode characters sbyte - 8-bit signed integral type sbyte - 8-bit signed integral type short - 16-bit signed integral type short - 16-bit signed integral type int - 32-bit signed integral type int - 32-bit signed integral type long - 64-bit signed integral type l long - 64-bit signed integral type l byte - 8-bit unsigned integral type byte - 8-bit unsigned integral type ushort - 16-bit unsigned integral type ushort - 16-bit unsigned integral type uint - 32-bit unsigned integral type uint - 32-bit unsigned integral type ulong - 64-bit unsigned integral type ulong - 64-bit unsigned integral type float - Single-precision floating point type float - Single-precision floating point type double - Double-precision floating point type double - Double-precision floating point type bool - Boolean type; a bool value is either true or false bool - Boolean type; a bool value is either true or false char - Character type; a char value is a Unicode character char - Character type; a char value is a Unicode character decimal - Precise decimal type with 28 significant digits decimal - Precise decimal type with 28 significant digits

Arrays int[] arr = new int[] {1, 2, 3, 4, 5}; 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};

Record Types struct Point { public int x, y; public int x, y; public Point(int x, int y) { public Point(int x, int y) { this.x = x; this.x = x; this.y = y; this.y = y; }}

Union Types [StructLayout(LayoutKind.Explicit)] public struct MyUnion { [FieldOffset(0)] public int x; [FieldOffset(0)] public double y; }

Pointer Types using System; class MyClass { public unsafe void Method() { int x = 10; int y = 20; int *ptr1 = &x; int *ptr2 = &y; Console.WriteLine((int)ptr1); Console.WriteLine((int)ptr2); Console.WriteLine(*ptr1); Console.WriteLine(*ptr2); } }

Sub Programs and Parameter Passing The way variables are passed is affected by two things: The way variables are passed is affected by two things: The data type of the parameter. The data type of the parameter. What modifiers are present when the parameter is passed. What modifiers are present when the parameter is passed.

Value vs. Reference Types The following types are passed by Value by default: The following types are passed by Value by default: Struct types Struct types Enumeration types Enumeration types Numeric types Numeric types Integral types Integral types Floating-point types Floating-point types decimal decimal bool bool

Parameter Modifiers ref – allows a value type to be passed by reference ref – allows a value type to be passed by reference out – allows a parameter to be passed as an out parameter out – allows a parameter to be passed as an out parameter

Parameter Modifiers class ParameterModifiers { static void Main(string[] args) { static void Main(string[] args) { int myInt = 9; int myInt = 9; modifyInt1(myInt); modifyInt1(myInt); Console.WriteLine(myInt); Console.WriteLine(myInt); modifyInt2(ref myInt); modifyInt2(ref myInt); Console.WriteLine(myInt); Console.WriteLine(myInt); modifyInt3(out myInt); modifyInt3(out myInt); Console.WriteLine(myInt); Console.WriteLine(myInt); Console.ReadLine(); Console.ReadLine(); } private static void modifyInt1(int myInt) { private static void modifyInt1(int myInt) { myInt++; myInt++; } public static void modifyInt2(ref int myInt) { public static void modifyInt2(ref int myInt) { myInt++; myInt++; } private static void modifyInt3(out int myInt) { private static void modifyInt3(out int myInt) { myInt++; myInt++; } }