Mads Torgersen Language PM for C# What’s new in C# 6.0.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Clonazione La clonazione... Ovvero: come costruire una copia (probabilmente che ritorni true su equals?)
IBM Research: Software Technology © 2006 IBM Corporation 1 Programming Language X10 Christoph von Praun IBM Research HPC WPL Sandia National Labs December.
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Roslyn: el futuro de C# Rodolfo Finochietti
Exceptions: when things go wrong. Various sources of error public static doSomething() { int i = 3.0; while(!done); { int i = false } ) Syntactic errors.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
What is new in the new version 6.0 of the C# programming language? Telerik Academy Plus C# 6.0 and Roslyn Seminar.
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
For use of Cleveland State's IST410 Students only 1 Exception.
Exceptions Any number of exceptional circumstances may arise during program execution that cause trouble import java.io.*; class IOExample { public static.
THE FUTURE OF C# KEVIN PILCH-BISSON MADS TORGERSEN
Exception examples. import java.io.*; import java.util.*; class IO { private String line; private StringTokenizer tokenizer; public void newline(DataInputStream.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Evolutie vs Revolutie Chris de Kok Evolutie vs Revolutie.NET 2015.NET 4.6 ASP.NET 5 -> MVC 6 Visual Studio 2015 C# 6.0 Agenda.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors reading:
CMSC 132 Week2 Lab1 Comparable vs Comparator clone() finalize()
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Program Errors Syntax errors Logic errors
1 Review of Java Higher Level Language Concepts –Names and Reserved Words –Expressions and Precedence of Operators –Flow of Control – Selection –Flow of.
Chapter 9: Exceptions For error/problem situations Exception classes –ArithmeticException, IOException, etc. –checked exceptions try blocks –catch statements.
Recitation 1 CS0445 Data Structures Mehmud Abliz.
Type Safety and Enumerations. Type Checking and Type Errors  The type system defines data types and the operations on data types.  A type error occurs.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
CSc2310 tutoring session, week 8 Fall, 2012 Haidong Xue 5:30pm—8:30pm 10/23/2012 and 10/24/2012 -Using Exceptions -Homework 4.
Problem Solving using the Java Programming Language May 2010 Mok Heng Ngee Day 5: Arrays.
ILM Proprietary and Confidential -
1 CONFIDENTIAL.NET FEATURES OVERVIEW C# 6 ASP.NET 5 DNX PROJECT ASP.NET MVC 6 EF 7 A UGUST 4, 2015.
Lagash Systems Mariano Sánchez – Software
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.

Problems.Net Анатолий Крыжановский Обра. ООП 2 class Bar { } void Foo(object a) { Console.WriteLine("object"); } void Foo(object a, object b) { Console.WriteLine("object,
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
Lecture 8: Object Oriented Programming. What is a Programming Object? An object is an instance of a class. A class is a template for an object. Everything's.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
1 SWIFT 2.0: New features Dzianis Astravukh AUGUST 5, 2015.
C# 6 - do it right Vedran Kaldi Senior
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
33) static void Main() { Action operations = MathOperations.MultiplyByTwo; operations += MathOperations.Square; ProcessAndDisplayNumber(operations, 2.0);
Writing Better C# Using C# 6 By: Mitchel Sellers.
Exception Handling SWE 344 Internet Protocols & Client Server Programming.
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
Strings in C++/CLI us/library/system.string.aspxhttp://msdn.microsoft.com/en- us/library/system.string.aspx public: static.
Barbara Doyle Jacksonville University What’s New with Visual Studio and C#?
C# Present and Future Marita Paletsou Software Engineer.
Object Oriented Programming Lecture 2: BallWorld.
Lecture 11 Dr. Eng. Ibrahim El-Nahry Exception Handling.
תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים
5/19/2018 1:01 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Future of C#
RADE new features via JAVA
New Features of C# Kuppurasu Nagaraj Microsoft Connect 2016
Code Magnets problem for wk5
Accessing Files in Java
New Features in C# 7.0 Mads Torgersen C# Program Manager
EE 422C Java Reflection re·flec·tion rəˈflekSH(ə)n/ noun
תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים
null, true, and false are also reserved.
Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,
Building Java Programs
Code Animation Examples
JavaScript Reserved Words
CSC 270 – Survey of Programming Languages
Developer Productivity: What’s New in C# 6
Building Java Programs
Chapter 13 Exception Handling: A Deeper Look
Exception Objects An exception is an abnormal condition that arises in a code sequence at rum time. Exception is a way of signaling serious problem.
Presentation transcript:

Mads Torgersen Language PM for C# What’s new in C# 6.0

No big new concepts Many small features Clean up your code Design philosophy

Getter-only auto-properties public class Point { public int X { get; set; } public int Y { get; set; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Getter-only auto-properties public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Getter-only auto-properties public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Initializers for auto-properties public class Point { public int X { get; } = 5; public int Y { get; } = 7; public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

String interpolation using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); }

String interpolation using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "(\{X}, \{Y})"; }

Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "(\{X}, \{Y})"; }

Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "(\{X}, \{Y})"; } () => { return "(\{X}, \{Y})"; } () => "(\{X}, \{Y})"

Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() => "(\{X}, \{Y})"; }

Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() => "(\{X}, \{Y})"; }

Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist => Sqrt(X * X + Y * Y); public override string ToString() => "(\{X}, \{Y})"; }

Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist => Sqrt(X * X + Y * Y); public override string ToString() => "(\{X}, \{Y})"; }

Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { var result = new JObject(); result["x"] = X; result["y"] = Y; return result; }

Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { var result = new JObject() { ["x"] = X, ["y"] = Y }; return result; }

Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { return new JObject() { ["x"] = X, ["y"] = Y }; }

Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() => new JObject() { ["x"] = X, ["y"] = Y }; }

Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"] != null && json["x"].Type == JTokenType.Integer && json["y"] != null && json["y"].Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }

Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }

Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; } ?.?.

Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }

Null-conditional operators public static Point FromJson(JObject json) { if (json?["x"]?.Type == JTokenType.Integer && json?["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }

Null-conditional operators OnChanged(this, args);

Null-conditional operators if (OnChanged != null) { OnChanged(this, args); }

Null-conditional operators { var onChanged = OnChanged; if (onChanged != null) { onChanged(this, args); }

Null-conditional operators OnChanged?.Invoke(this, args);

The nameof operator public Point Add(Point point) { if (point == null) { throw new ArgumentNullException("point"); }

The nameof operator public Point Add(Point other) { if (other == null) { throw new ArgumentNullException("point"); }

The nameof operator public Point Add(Point point) { if (point == null) { throw new ArgumentNullException(nameof(point)); }

The nameof operator public Point Add(Point other) { if (other == null) { throw new ArgumentNullException(nameof(other)); }

Exception filters try { … } catch (ConfigurationException e) { } finally { }

Exception filters try { … } catch (ConfigurationException e) if (e.IsSevere) { } finally { }

Await in catch and finally try { … } catch (ConfigurationException e) if (e.IsSevere) { await LogAsync(e); } finally { await CloseAsync(); }

roslyn.codeplex.com Learn more at …