小编Jam*_*346的帖子

C#NOT(〜)位智能运算符返回负值

为什么C#的按位运算NOT符返回(the_number*-1)-1

byte a = 1;
Console.WriteLine(~a); //equals -2
byte b = 9;
Console.WriteLine(~b); //equals -10
// Shouldn't a=0 and b=6?
Run Code Online (Sandbox Code Playgroud)

我怎么用C#做这个?

9 = 0b1001 -> NOT
  = 0b0110 = 6
Run Code Online (Sandbox Code Playgroud)

c# bit bitwise-operators

5
推荐指数
1
解决办法
3985
查看次数

C#File.ReadAllText返回"NotSupportedException"

File.ReadAllText似乎存在问题,因为即使目标文件存在,它也会返回"NotSupportedException".无论放入什么参数,它都会不断抛出相同的异常.

using System;
using System.IO;

namespace MyNameSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(File.ReadAllText(@"?C:\Test.txt"));
            Console.ReadKey();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

是的... Text.txt确实存在于此目录中.StreamReader有完全相同的问题.这有什么解决方法吗?

编译器注释:"附加信息:不支持给定路径的格式."

c# file filereader

2
推荐指数
1
解决办法
624
查看次数

标签 统计

c# ×2

bit ×1

bitwise-operators ×1

file ×1

filereader ×1