Created
October 7, 2014 13:52
-
-
Save ufcpp/51bbca95d4fe76a5f0cf to your computer and use it in GitHub Desktop.
C# vNext in VS 14 CTP 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Math; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var dic = new Dictionary<string, int> | |
{ | |
["one"] = 1, | |
["two"] = 2, | |
}; | |
Console.WriteLine(dic["one"]); | |
Console.WriteLine(dic["two"]); | |
RunAsync().Wait(); | |
} | |
public static async Task RunAsync() | |
{ | |
try | |
{ | |
await Task.Delay(30); | |
throw new InvalidOperationException( | |
"dummy error in " + nameof(RunAsync)); | |
} | |
catch (Exception ex) if (ex.Message.Contains("dummy")) | |
{ | |
await Task.Delay(30); | |
Console.WriteLine(ex.Message); | |
} | |
finally | |
{ | |
await Task.Delay(30); | |
} | |
} | |
} | |
} | |
struct Point | |
{ | |
public int X { get; } = 30; | |
public int Y { get; } = 50; | |
public double Norm => Sqrt(X * X + Y * Y); | |
public override string ToString() => "(" + X + ", " + Y + ")"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment