New Features in C# 2.0 Sergey Baidachni MCT, MCSD, MCDBA.

Slides:



Advertisements
Similar presentations
1 Visual C# "Whidbey": Language Enhancements Anders Hejlsberg Distinguished Engineer Microsoft Corporation Anders Hejlsberg Distinguished.
Advertisements

Generics Programming in C# Generics CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
New features in JDK 1.5 Can these new and complex features simplify Java development?
Brown Bag #2 Advanced C++. Topics  Templates  Standard Template Library (STL)  Pointers and Smart Pointers  Exceptions  Lambda Expressions  Tips.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
1 ADT and Data Structure Example Generics / Parameterized Classes Using a Set Implementing a Set with an Array Example: SetADT interface Example: ArraySet.
Generics and The ArrayList Class
How to be a C# ninja in 10 easy steps. Benjamin Day.
Java Generics. 2 The Dark Ages: Before Java 5 Java relied only on inclusion polymorphism  A polymorphism code = Using a common superclass Every class.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
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.
Iterator Pattern Dr. Neal CIS 480. Iterator An iterator pattern can be used when one class is a collection of things and would like to provide a standardized.
Topic 6 Generic Data Structures "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
CS 307 Fundamentals of Computer Science ADTS and Generic Data Structures 1 Topic 12 ADTS, Data Structures, Java Collections and Generic Data Structures.
C# Programming: From Problem Analysis to Program Design1 10 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
PARALLEL PROGRAMMING ABSTRACTIONS 6/16/2010 Parallel Programming Abstractions 1.
C# vs. C++ What's Different & What's New. An example C# public sometype myfn { get; set; } C++ public: sometype myfn { sometype get (); void set (sometype.
OOP Languages: Java vs C++
Templates CS212 & CS-240. Reuse Templates allow extending our classes Allows the user to supply certain attributes at compile time. Attributes specified.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 7 th & 8 th Lecture Pavel Ježek.
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
Mobile Computing Lecture#11 Adapters and Dialogs.
Interfaces 1. Interfaces are (parts of) contracts Interfaces are contracts between implementers and consumers Consumers: Programmers using a class implementing.
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
How to be a C# ninja in 10 easy steps Benjamin Day.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Jon Shemitz Complicated stuff, quickly..NET 2.0. ● Generics50% & Nullable Types ● Iterators 10% ● Delegate Enhancements35% ● Partial Types5%
Modern Software Development Using C#.NET Chapter 5: More Advanced Class Construction.
ILM Proprietary and Confidential -
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
Chapter 14 Generics and the ArrayList Class Slides prepared by Rose Williams, Binghamton University Copyright © 2008 Pearson Addison-Wesley. All rights.
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
C# 2.0 and Future Directions Anders Hejlsberg Technical Fellow Microsoft Corporation.
Programming in Java CSCI-2220 Object Oriented Programming.
C# Programming: From Problem Analysis to Program Design1 10 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
C Sharp Web & Internet Programming Group Diana, Aren, Jeff, & Adam, Farrin 5/5/20081CS 311.
Advanced C# Types Tom Roeder CS fa. From last time out parameters difference is that the callee is required to assign it before returning not the.
Overview of C++ Templates
3C-1 Purity Typing Language semantics Inheritance model  Single vs. Multiple inheritance  Common root Modular mechanisms Generics Object Oriented Languages.
Oct 2007 SDP-MSc Slide 1 Section 9 Graphic Programming.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
Neal Stublen Tonight’s Agenda  Indexers  Delegates and events  Operator overloading  Class inheritance  Q&A.
Principles of Object-Oriented Software Development The language C++
Generic Data Structures "Get your data structures correct first, and the rest of the program will write itself." - David Jones EE 422CGenerics 1.
Advanced C#, part I Niels Hallenberg IT University of Copenhagen BAAAP – Spring 2009.
Introduction to C# 2.0 An Advanced Look Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP – C#
PROGRAMMING IN C#. Collection Classes (C# Programming Guide) The.NET Framework provides specialized classes for data storage and retrieval. These classes.
Generics in C# 1. Generics List vs. non-generic ArrayList Generic List Namespace System.Collections.Generic List list = new List (); List.add(”Anders”);
Generics Generics vs. heterogeneous collections Doing your own generics FEN 2014UCN Teknologi/act2learn1.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 11 th Lecture Pavel Ježek
1 CSC 2053 New from AutoBoxing 3 Before J2SE 5.0, working with primitive types required the repetitive work of converting between the primitive.
Session 02 Module 3: Statements and Operators Module 4: Programming constructs Module 5: Arrays.
Classes Classes are a major feature of C++. They support – – Abstraction – Data hiding – Encapsulation – Modularity – Re-use through inheritance.
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
1 New Features in C# 2.0 Generic Types Iterators Simplified Delegates Anonymous Methods Partial Types Various © University of Linz, Institute for System.
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
CPSC 252 Templatization Page 1 Templatization In CPSC152, we saw a class vector in which we could specify the type of values that are stored: vector intData(
Module 5: Programming with C#. Overview Using Arrays Using Collections Using Interfaces Using Exception Handling Using Delegates and Events.
Lecture 09 Dr. Eng. Ibrahim El-Nahry C# - Structures, Enumerations and Partial Classes.
Sixth Lecture ArrayList Abstract Class and Interface
C# Operator Overloading and Type Conversions
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005
Conditional Statements
Presentation transcript:

New Features in C# 2.0 Sergey Baidachni MCT, MCSD, MCDBA

C# ver. 2.0  Generics  Iterators  Partial types  Anonymous method

Generics  Array of object?  What is it?  How to create Generics

Array of object?  Boxing and Unboxing ArrayList list=new ArrayList(); list.Add(4); list[0]=(int)list[0]+1;  Explicit conversion int j; j=(int)list[0]; //unboxing  Problem with performance and exceptions

Generics (What is it?)  Templates in C++  No problem with performance List list=new List[int](); list.add(2); list.add(“table”); //compilation error  No problem with conversion int j; j=list[0];

How create Generics (base syntaxes)  Please use any name for your type class MyClass { private ItemType item; }  Limitation: You can use only methods inherited from object

Generics (extensions)  Use Where in order to extend your possibilities Class MyClass where T1: IMyInterface where T2: IComparable {…..}  Interfaces public interface IMyInterface { void WhatIsIt(T i); }

Iterators  Enumerators vs. Iterators  yield keyword public IEnumerator GetEnumerator() { for(int i = 1;i< 5;i++) { yield return i; if(i > 2) yield break; }  Benifits

Partial Types  One class – many files?  partial keyword //first file (MyClass_1.cs) public partial class MyClass { private int nCount;..... } //second file (MyClass_2.cs) public partial class MyClass { private bool isPresent..... }

Anonymous method  Too lazy to write a separate method? There’s no need to. Button b=new Button(); b.Click+= new Button.ClickEventHandler(object s,EventArgs e) { Console.WriteLine(“Hello”); };  You can use local variable  new? Who needs it?

Books .NET Framework: Secret tips on Windows Applications Creation by Sergey Baidachni .NET Framework: Secret tips on Web- application creation by Sergey Baidachni (coming up soon)