1

According to MSDN: \ooo ASCII character in octal notation

The following code is showing Octal character($) in c#:

char character36 = '\o44';
Console.Write(character36);

but it doesn't work.

rivas
  • 15
  • 4
  • 1
    "but it doesn't work." --- what does it exactly mean? "According to MSDN: \ooo ASCII character in octal notation" --- and please provide a link to that. – zerkms Oct 23 '16 at 10:38
  • will it be compiled ? – Vivek Nuna Oct 23 '16 at 10:43
  • 3
    The link you provided is about C programming language not C#. – zerkms Oct 23 '16 at 10:46
  • @zerkms Oops, sorry, that's my fault. I think I just made things worse, I rolled back my edit. I do think the OP was reading that part of the documentation, but I totally missed that it wasn't applicable. –  Oct 23 '16 at 10:48
  • @DavidG Not quite a duplicate of that, though. Octal literals and octal escape sequences are two different things. –  Oct 23 '16 at 10:52
  • @hvd Yeah, I was hunting for something better. Either way C# doesn't have octal escape sequence either. – DavidG Oct 23 '16 at 10:53
  • 1
    @hvd, in my opinion, this is good enough. This is a very basic question, and the information in the linked duplicate is more than enough to set OP on the right track. – Andrew Savinykh Oct 23 '16 at 10:54
  • @AndrewSavinykh I don't agree that the information in those answers are relevant to this question, but I made enough mistakes already, so I'll avoid risking one more and leave it closed. –  Oct 23 '16 at 11:07
  • @hvd Happy to reopen if you find a better one to hammer? – DavidG Oct 23 '16 at 11:12
  • @DavidG I did search and didn't find one. I suspect that this may not be a duplicate at all, certainly not of any popular question, but I'm not confident in that to re-open. –  Oct 23 '16 at 11:16

1 Answers1

1

In Escape Sequences, which I suspect you were reading, the "ooo" is italicised to indicate that it should not be included verbatim. It should be replaced by the appropriate octal digits. "o44" aren't octal digits, you included a literal "o". The appropriate octal digits would be "044", or just "44".

But as pointed out by Andrew Savinykh, this is a documentation page about C, not about C#, and C# does not use the same syntax. It doesn't have octal escape sequences at all. The escape sequences for C# are documented on Strings (C# Programming Guide), and do not include any octal escape sequences unless you want to include the special exception of \0. You can use hexadecimal escape sequences instead, either \u0024 or \x24.