Using escape sequences in identifiers C# with Example



Using escape sequences in identifiers C# with Example

Escape sequences are not restricted to string and char literals. 
 

Suppose you need to override a third-party method: 
protected abstract IEnumerable ObtenirŒuvres(); 
and suppose the character Πis not available in the character encoding you use for your C# source files. You are 
lucky, it is permitted to use escapes of the type \u#### or \U######## in i d ent ifie rs in the code. So it is legal to 
write: 
protected override IEnumerable Obtenir\u0152uvres() 
{ 
// ... 
} 
and the C# compiler will know Πand \u0152 are the same character. 
(However, it might be a good idea to switch to UTF-8 or a similar encoding that can handle all characters.) 

0 Comment's

Comment Form