如何将空文件夹(无文件)添加到 Git 存储库?提交包含文件的文件夹然后删除它们的选项不合适。
Andrei Khotko
Asked:
2020-02-02 16:16:53 +0000 UTC
从性能的角度来看,我对这个问题很感兴趣。关于对象需要类型转换这一事实,我知道因此您可能会隐式出错。
更新。这个问题是在采访中被问到的。例如,我添加了 2 个类:
class SomeClass<T>
{
private T[] storage;
}
class SomeClass
{
private object[] storage;
}
Vadim Prokopchuk
Asked:
2020-02-01 04:56:22 +0000 UTC
如何在 C# 中正确比较字符串:Equalsor ==?
string str1 = "s";
string str2 = "s";
Console.WriteLine("eq: " + str1.Equals(str2));
Console.WriteLine("==: " + (str1 == str2));
在这两种情况下,结果True都是尽管String是一个类并且运算符==必须比较引用。
IlDasm表明根据方法创建并比较了 2 个变量Equals,== (op_Equality)
IL_0000: nop
IL_0001: ldstr "s"
IL_0006: stloc.0
IL_0007: ldstr "s"
IL_000c: stloc.1
IL_000d: ldstr "eq: "
IL_0012: ldloc.0
IL_0013: ldloc.1
IL_0014: callvirt instance bool [mscorlib]System.String::Equals(string)
IL_0019: box [mscorlib]System.Boolean
IL_001e: call string [mscorlib]System.String::Concat(object, object)
IL_0023: call void [mscorlib]System.Console::WriteLine(string)
IL_0028: nop
IL_0029: ldstr "==: "
IL_002e: ldloc.0
IL_002f: ldloc.1
IL_0030: call bool [mscorlib]System.String::op_Equality(string, string)
IL_0035: box [mscorlib]System.Boolean
IL_003a: call string [mscorlib]System.String::Concat(object, object)
rikimaru2013
Asked:
2020-01-20 05:38:32 +0000 UTC
此代码是否包含 UB?
int i = 6;
i = 7, ++i, i++;