The first is the nameof() operator, that will give you the name of the thing in the parentheses. A typical example of using it is:
void f(string s)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
}
The second is string interpolation. This allows you to do
string foo = $"{name} works in {department} and has {employeeCount} employees";
rather than
string foo = string.Format("{0} works in {1} and has {2} employees", name,
department, employeeCount);
The exact details are in the links.
Also interesting is the discussion about these as they work out the details. You can find the details of the design decisions on the CSharp Language Design Notes page. The process they are going through to design these features gives you insight into the features themselves. It is cool to see this being done in public rather than in some conference room in Redmond.
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.