c# - Special characters for dynamic objects? -


is there limitations on kind of characters can use create property dynamic object?

is there list of characters cannot use (e.g. / * @)?

suppose have:

dynamic eo = new expandoobject(); 

then if expand object through c# syntax, need follow c# rules, example:

eo.validcsharpidentifier = 42; eo._ok = 42; eo.æ = 42; 

but if expand eo casting idictionary<,>, can use other characters:

((idictionary<string, object>)eo).add("notvalidc#identifier", 42); ((idictionary<string, object>)eo).add("42", 42); ((idictionary<string, object>)eo).add("/", 42); ((idictionary<string, object>)eo).add("*", 42); ((idictionary<string, object>)eo).add("@", 42); ((idictionary<string, object>)eo).add("", 42); 

as see, strange identifiers possible. string must object though, null reference cannot used (as in .add(null, 42) /* illegal */).

there seems no restriction on name used. string keys seem compared ordinal string comparison, in equalitycomparer<string>.default or stringcomparer.ordinal.

certainly, .net languages have different rules valid characters in names, compared c# rules.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -