Octal equivalent in C#

前端 未结 5 935
名媛妹妹
名媛妹妹 2020-12-16 08:56

In C language octal number can be written by placing 0 before number e.g.

 int i = 012; // Equals 10 in decimal.

I found the e

5条回答
  •  粉色の甜心
    2020-12-16 09:46

    No, there are no octal literals in C#.

    If necessary, you could pass a string and a base to Convert.ToInt32, but it's obviously nowhere near as nice as a literal:

    int i = Convert.ToInt32("12", 8);
    

提交回复
热议问题