有关.NET和C#的一些更棘手的问题



我从.NET和C#的世界中为您选择了一些有趣但不是非常知名的问题。另外,我根据自己喜欢的书籍,文章和视频自己写了一些问题。

1.屏幕上将显示什么?(如果什么都没有显示)

string nullString = (string)null;
Console.WriteLine (nullString is string);


2.控制台.NET应用程序将显示什么?

Console.WriteLine (Math.Round(1.5));
Console.WriteLine (Math.Round(2.5));

回答
2 2. — . , Mono 2 3.

3.执行以下代码将导致什么结果:

static void Main(string[] args)
{
    float f = Sum(0.1f, 0.2f);
    float g = Sum(0.1f, 0.2f);
    Console.WriteLine(f == g);
}

static float Sum(float f1, float f2)
{
    return f1 + f2;
}

a)正确
b)错误
c)将引发异常
d)不能明确地说(很可能是正确的,但也可能是错误的)

回答
d
JIT float. , , CLR, ( , , ). Debug/Release , , False. , — Release False. . , .
Credits:
Binary floating point and .NET

4.执行以下代码将导致什么结果:

float price = 4.99F;
int quantity = 17;
float total = price * quantity;
Console.WriteLine("The total price is ${0}.", total);

a)总价为$ 85
b)总价为$ 84.83
c)总价为$ 84
d)总价为$ 84.82999


5.在数据库中存储密码的最佳方法是什么?选择一个或多个答案:

a)为纯文本
b)使用DES加密
c)使用AES加密
d)使用MD5
缓存e)使用SHA512缓存

回答
e
MD5 .
, keyed hash : HMACSHA1 MACTripleDES

6.在.NET环境中,有许多不同的计时器。哪个计时器不存在?

a)来自System.Windows.Forms的计时器
b)来自System.Windows.Threading的DispatchTimer
c)来自Windows.UI.XAML的DispatchTimer
d)来自System.Timers的
计时器e)来自System.Windows.Threading.Timers的
计时器f)来自系统的计时器。穿线

回答
e
Credits: CLR via C# Jeffrey Richter

7.网络上不存在什么.NET REPL?

a)dotnetfiddle.net
b)repl.it/语言/ csharp
c)csharpcompiler.net
d)dotnet.microsoft.com/platform/try-dotnet
e)csharppad.com

回答
c

8.如果要指示数字的类型为long,则可以在数字的末尾指定字母l或L.例如:

var l = 138l;

我可以使用哪个字母指定小数类型?

a)C或c
b)D或d
c)M或m
d)E或e

回答
c

9.控制台应用程序的屏幕上将显示包含以下代码的内容:

     class Program
    {
         static Program()
        {
            Console.WriteLine("Static constructor");
        }

         public Program()
        {
            Console.WriteLine("Constructor");
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Main");
            Console.ReadLine();
        }
    }

回答
«Static constructor» «Main»
, . . .

10.结果将显示什么?

      [Flags]
      public enum Status 
      {
         Funny = 0x01,
         Hilarious = 0x02,
         Boring = 0x04,
         Cool = 0x08,
         Interesting = 0x10,
         Informative = 0x20,
         Error = 0x40
      }

  public static void Main (string[] args) {
         var code = 24;
         Console.WriteLine (String.Format("This Quiz is: {0}",  (Status)code));
      }

回答
This Quiz is: Cool Interesting

24 0011000

Funny = 0
Hilarious = 0
Boring = 0
Cool = 1
Interesting = 1
Informative = 0
Error = 0
Credits:
C# Often Surprises Me, part: 000001
Enumeration types (C# reference)


11. String和string有什么区别?

回答
String .NET c# string. short int C# Int16 Int32 .NET
Difference between string and String in C#

12. Visual Studio符号是什么意思(或至少最初是什么意思)?


13.请映射:
异步/等待
尝试/捕获 带有以下缩写的
ValidateAntiForgeryToken

TAPSEHSTP

回答
Async/await -> TAP (Task asynchronous programming model)
Try/catch -> SEH (Structured Exception Handling)
ValidateAntiForgeryToken -> STP (Synchronizer Token Pattern)

14.以下哪个不是.NET CMS?

a)mojoPortal
b)N2 CMS
c)原子CMS
d)复合材料C1
e)混凝土5
f)Piranha CMS

回答
e

15.屏幕上将显示什么?(如果显示了某些内容)

  
     class Program
    {
        private static int y = x;
        private static int x = 5;

        static void Main(string[] args)
        {
            Console.WriteLine(y);
            Console.ReadLine();
        }
    }

回答
0


16. .Net中不存在什么类的并发集合

a)ConcurrentQueue
b)ConcurrentStack
c)ConcurrentList
d)ConcurrentDictionary
e)ConcurrentBag

回答
c

17.最好使用哪种方法以同步方式调用异步代码(当然,在很少的情况下,当await无法正常工作时,可以这样做):

a)Wait()
b)Result()
c)GetAwaiter()。GetResult()

回答

All Articles