Tag: language lawyer

volatile是否会阻止引入读取或写入?

在C#中, volatile关键字分别确保读取和写入具有获取和释放语义。 但是,是否有关于引入读取或写入的内容? 例如: volatile Thing something; volatile int aNumber; void Method() { // Are these lines… var local = something; if (local != null) local.DoThings(); // …guaranteed not to be transformed into these by compiler, jitter or processor? if (something != null) something.DoThings(); // <– Second read! // Are these lines… if (aNumber == […]

C#需要私有关键字吗?

(受此评论的启发) 是否存在需要使用private关键字的情况? (换句话说,省略关键字会导致不同行为的情况)