官方文档: 任务异步编程模型正确的答案 --> var contacts = new List<string>();
var type = typeof(SomeType); var attribute = type.GetCustomAttribute<SomeAttribute>();
var typeof(MyPresentationModel).Should().BeDecoratedWith<SomeAttribute>();
Attribute.GetCustomAttribute, typeof(SubControllerActionToViewDataAttribute)
Attribute.GetCustomAttribute(typeof(ExampleController), typeof(SubControllerActionToViewDataAttribute))
private static object objA;
private static object objB;
private static void performTaskA()
{
lock (objB)
{
Thread.Sleep(1000);
lock (objA) { }
}
}
private static void PerformTaskB()
{
lock (objA)
{
lock (objB) { }
}
}
==
比较内容。 ==
比较所有值。 ==
比较引用标识。 ==
比较原始值类型 var<<!---->T> userData = new <<!---->T> { name = "John", age = 32 };
var userData = new { name = "John", age = 32 };
AType userData = new AType { name = "John", age = 32 };
Anonymous<T> userData = new Anonymous<T> { name = "John", age = 32 };
string[] employees = { "Joe", "Bob", "Carol", "Alice", "Will" };
IEnumerable<string> employeeQuery = from person in employees
orderby person
select person;
foreach(string employee in employeeQuery)
{
Console.WriteLine(employee);
}