I am looking for reading .Net, C# reserved key words programmatically in VS 2015.
I got the answer to read C# reserved words in the [link][1].
CSharpCodeProvider cs = new CSharpCodeProvider();
var test = cs.IsValidIdentifier("new"); // returns false
var test2 = cs.IsValidIdentifier("new1"); // returns true
But for var
, dynamic
, List
, Dictionary
etc the above code is returning wrong result.
Is there any way to identify .net keywords in run time instead of listing key words in a list?
string[] _keywords = new[] { "List", "Dictionary" };
var
nordynamic
norList
are keywords. Please explain your question. – Forenoonvar
be a keyword in your example? Because it's not a reserved word. – Forenoon