c# 命名空间命名规范_C#命名空间能力问题和解答 套装3

c# 命名空间命名规范

1) There are following namespaces are given below, which is correct about "using" statement in C#.NET?
  1. In C#.Net, "using" statement is used to import the namespace in our program

  2. We can create a new namespace with the help of "using" statement

  3. We cannot use "using" statement in C#.NET

  4. We can use "using" statement in VB.NET only

Answer & Explanation

Correct answer: 1
In C#.Net, "using" statement is used to import the namespace in our program

In the given statement, 1st statement is correct.

1)下面给出了以下名称空间,这与C#.NET中的“ using”语句正确吗?
  1. 在C#.Net中,“ using”语句用于在我们的程序中导入名称空间

  2. 我们可以在“ using”语句的帮助下创建一个新的命名空间

  3. 我们不能在C#.NET中使用“使用”语句

  4. 我们只能在VB.NET中使用“使用”语句

答案与解释

正确答案:1
在C#.Net中,“ using”语句用于在我们的程序中导入名称空间

在给定的语句中,第一个语句是正确的。

2) We created a library, in which a namespace that contains classes, then what is the correct way to use classes present in a namespace?
  1. Add reference of the library then use classes present in the namespace.

  2. Add reference of the library and include namespace into the project and then we can use classes present in the namespace.

  3. Include namespace in our project then use classes present in the namespace.

  4. We need to install namespace into GAC and then we can use classes present in the namespace.

Answer & Explanation

Correct answer: 2
Add reference of the library and include namespace into the project and then we can use classes present in the namespace.

In the given statement, the 2nd statement is correct.

2)我们创建了一个库,其中一个包含类的名称空间,那么使用名称空间中存在的类的正确方法是什么?
  1. 添加对库的引用,然后使用名称空间中存在的类。

  2. 添加库的引用,并将命名空间包含到项目中,然后我们可以使用命名空间中存在的类。

  3. 在我们的项目中包含名称空间,然后使用名称空间中存在的类。

  4. 我们需要将名称空间安装到GAC中,然后才能使用名称空间中存在的类。

答案与解释

正确答案:2
添加库的引用,并将命名空间包含到项目中,然后我们可以使用命名空间中存在的类。

在给定的语句中,第二条语句正确。

3) Is it possible that we can use multiple using statements in a program in C#.NET?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

Yes, we can use multiple using statements in a program.

3)是否可以在C#.NET的程序中使用多个using语句?
  1. 没有

答案与解释

正确答案:1

是的,我们可以在一个程序中使用多个using语句。

4) What is the correct output of the given code snippet?
using System;

namespace my_namespace
{
    class sample
    { 
        public static void sayHello()
        {
            Console.WriteLine("Hello");
        }
    }

    class program
    {
        static void Main(string[] args)
        {
            sample.sayHello();
        }
    }
}

  1. Syntax error

  2. Hello

  3. Linker error

  4. Runtime exception

Answer & Explanation

Correct answer: 2
Hello

The above code will print "Hello" on console screen.

4)给定代码段的正确输出是什么?
  1. 语法错误

  2. 你好

  3. 链接器错误

  4. 运行时异常

答案与解释

正确答案:2
你好

上面的代码将在控制台屏幕上打印“ Hello”

5) How many classes can be created in a namespace?
  1. 2

  2. 1

  3. Any number of classes

  4. 5

Answer & Explanation

Correct answer: 3
Any number of classes

We can create any number of classes in a namespace.

5)在一个命名空间中可以创建多少个类?
  1. 2

  2. 1个

  3. 任意数量的班级

  4. 5

答案与解释

正确答案:3
任意数量的班级

我们可以在名称空间中创建任意数量的类。

翻译自: https://www.includehelp.com/dot-net/csharp-namespace-aptitude-questions-and-answers-3.aspx

c# 命名空间命名规范

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值