小编Foo*_*Bar的帖子

找不到命名空间!

我创建了一个解决方案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

我为什么要这个?

这是怎么回事?

.net c# using reference

6
推荐指数
1
解决办法
1万
查看次数

如果声明|| 要么 &&

我在编写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或空有意义.这是这种情况吗?

为&&做什么?还是短路?

谢谢.

c# java if-statement

3
推荐指数
2
解决办法
498
查看次数

标签 统计

c# ×2

.net ×1

if-statement ×1

java ×1

reference ×1

using ×1