我创建了一个解决方案Foo.添加了一个名为Foo.Common
Added a console app的类库,用于调用来自调用的库代码ConsoleApp.
我引用了Foo.CommonfromConsoleApp和typed:
using Foo.Common;
public class Program
{
CommonClass c = new CommonClass();
static void Main(string[] args)
{
}
}
Run Code Online (Sandbox Code Playgroud)
并得到这个:
Error 1 The type or namespace name '**Foo**' could not be found (are you missing a using directive or an assembly reference?) Z:\Foo\Solution1\ConsoleApplication1\Program.cs 3 11 ConsoleApplication1
我为什么要这个?
这是怎么回事?
我在编写if语句时遇到问题如下:
public void foo(List<String> list)
{
if(list == null || list.isEmpty()){
// something
}
// else
}
Run Code Online (Sandbox Code Playgroud)
这是困扰我的:如果list为null list.IsEmpty()将失败(抛出异常,我在null对象上调用一个方法),因为list为null.但是,因为我做了|| (或)如果list为null(这是真的),它将执行第二个块.会抛出异常.
它是否正确?在英语中,如果列表为null或空有意义.这是这种情况吗?
为&&做什么?还是短路?
谢谢.