Thursday, October 1, 2015

nameof in C#

...is going to return a stringification of a variable name. The following test passes:

[TestMethod]
public void Test()
{
   Tuple<string,int> foo = new Tuple<string,int>("lucky",13);
   Assert.AreEqual("foo", nameof(foo));
}

No comments:

Post a Comment