例如,为什么long int有一个文字修饰符,但是short int不是?我指的是这个网站上的以下问题:C#编译器编号文字
通常,C#似乎是一种设计良好且一致的语言.可能有一个强有力的理由为某些类型提供文字修饰符,但不是所有类型.它是什么?
我使用continuationWith(anotherTask)创建一个任务,如下所示.我想找出第一项任务完成工作所需的时间.我在task1和子任务之间共享变量"task1StartedDateTime".这会没有任何问题吗?
public static void MyMethod()
{
var task1StartedDateTime = DateTime.Now;
var task1 = doWorkAsync();
task1.ContinueWith(t1 => {
var task1TookTime = DateTime.Now - task1StartedDateTime;
Console.WriteLine($"Task 1 took {task1TookTime}");
//Some other work of this child task
});
}
Run Code Online (Sandbox Code Playgroud)