Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created October 7, 2014 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ufcpp/51bbca95d4fe76a5f0cf to your computer and use it in GitHub Desktop.
Save ufcpp/51bbca95d4fe76a5f0cf to your computer and use it in GitHub Desktop.
C# vNext in VS 14 CTP 4
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