跳轉到內容

C# 程式設計/關鍵字/await

來自華夏公益教科書,開放的書籍,開放的世界

在非同步程式設計中使用asyncawait上下文關鍵字。 非同步程式設計允許一個程序等待一個方法完成並返回一個值(或超時或以其他方式失敗)。 關鍵字async必須用於修改包含await表示式或方法的方法或lambda表示式。 這兩個關鍵字使非同步程式設計易於實現。 只需在任何可能執行時間長的呼叫之前加上await關鍵字,例如,var text = await getLargeDataSet(); 並將async修飾符新增到包含方法(或lambda表示式)。 async 和 await 關鍵字在 JavaScript 和其他語言中可用,並在 C# 5.0 版本中引入。



C# 關鍵字
abstract as base bool break
byte case catch char checked
class const continue decimal default
delegate do double else enum
event explicit extern false finally
fixed float for foreach goto
if implicit in int interface
internal is lock long namespace
new null object operator out
override params private protected public
readonly ref return sbyte sealed
short sizeof stackalloc static string
struct switch this throw true
try typeof uint ulong unchecked
unsafe ushort using var virtual
void volatile while
特殊的 C# 識別符號(上下文關鍵字)
add alias async await dynamic
get global nameof partial remove
set value when where yield
上下文關鍵字(在查詢中使用)
ascending by descending equals from
group in into join let
on orderby select where
華夏公益教科書