Below are some features that may be a part of C#.6 and VB.12. For current information visit Language feature implementation status for Dev14
Feature status as of 10/3/2014:
Feature
Example
C#
VB
Primary constructors
class Point(int x, int y) { … }
No
Auto-property initializers
public int X { get; set; } = x;
Done
Exists
Getter-only auto-properties
public int Y { get; } = y;
Ctor assignment to getter-only autoprops
Y = 15
Parameterless struct ctors
Structure S : Sub New() : End Sub : End Structure
Using static members
using System.Console; … Write(4);
Dictionary initializer
new JObject { ["x"] = 3, ["y"] = 7 }
Indexed member initializer
new JObject { $x = 3, $y = 7 }
Indexed member access
c.$name = c.$first + " " + c.$last;
Declaration expressions
int.TryParse(s, out var x);
Await in catch/finally
try … catch { await … } finally { await … }
Maybe
Exception filters
catch(E e) if (e.Count > 5) { … }
Typecase
Select Case o : Case s As String : …
Guarded cases
Select Case i : Case Is > 0 When i Mod 2 = 0
Partial modules
Partial Module M1
N/A
Partial interfaces
Partial Interface I1
Multiline string literals
"HelloWorld"
Year-first date literals
Dim d = #2014-04-03#
Binary literals
0b00000100
Digit separators
0xEF_FF_00_A0
Line continuation comments
Dim addrs = From c in Customers ' comment
TypeOf IsNot
If TypeOf x IsNot Customer Then …
Expression-bodied members
public double Dist => Sqrt(X * X + Y * Y);
Event initializers
new Customer { Notify += MyHandler };
Null propagation
customer?.Orders?[5]?.$price
Planned
Semicolon operator
(var x = Foo(); Write(x); x * x)
Private protected
private protected string GetId() { … }
Params IEnumerable
int Avg(params IEnumerable numbers) { … }
Constructor Inference
new Tuple(3, "three", true);
String interpolation
"\{p.First} \{p.Last} is \{p.Age} years old."
TryCast for nullable
Dim x = TryCast(u, Integer?)
Delegate combination with +
d1 += d2
Implicit implementation
Class C : Implicitly Implements I
nameof operator
string s = nameof(Console.Write);
Strict modules
Strict Module M
Faster CInt
Dim x = CInt(Math.Truncate(d)) |
#pragma
#Disable Warning BC40008
Checked and Unchecked blocks
Checked : x += 1 : End Checked
Field targets on autoprops
Serializable> Property p As Integer
If(b,e1,e2) uses type context
Dim x As Integer? = If(b,1,Nothing)
Way back in 2000 Microsoft announced C#, and the rest is history.
Excerpt:
REDMOND, Wash., June 26, 2000 — Microsoft Corp. today announced Microsoft® ( "C sharp" ), a modern, object-oriented programming language built from the ground up to exploit the power of XML-based Web services on the .NET platform, which was announced last week at Forum 2000. With its Visual C++® development system heritage, C # will enable millions of C and C++ developers to use existing skills to rapidly build sophisticated XML-based .NET applications. To simplify integration and interoperability, Microsoft is working with ECMA, an international standards body, to create a standard for C # , enabling multiple vendors to deliver the language and supporting tools.
Read the entire announcement
With Microsoft Roslyn you can write applications that evaluate code at runtime.
While it’s been possible to implement scripting since the release of .Net it’s not been easy. Check out Brian Rasmussen’s blog on scripting:
Learn about the Roslyn scripting API
Until now the VB and C# compilers have been black boxes, un accessible to Microsoft.Net developers.
Enter Microsoft Roslyn, “a set of APIs for exposing the Microsoft C# and Visual Basic .NET compilers as services available at runtime.”
This software is currently available as a community technology preview (CTP).
Roslyn can be imagined as a “compiler as a Windows service” which VB and C# developers can access through the new Roslyn APIs.
It allows the entire compile-execute process to be invoked from within .Net applications to, for example, give VB and C# a dynamic languages ability to generate and invoke code at runtime.
Or, how about incorporating Roslyn into a .NET application that accepts user input then uses Roslyn APIs to process the input (remember how good old class VB could evaluate a string?)
Roslyn is powerful but you won’t know how powerful it is until you try it out yourself.
Download it today!
public static class ExtNumbers
{
public static decimal ToDecimal(this string value)
decimal result = Con.D0000m;
if (String.IsNullOrEmpty(value))
return result;
}
decimal.TryParse(value, out result);