內容相關性關鍵字 (C++/CLI 和 C++/CX)

「內容相關性關鍵字」是只能在特定內容中辨識的語言元素。 在特定內容之外,內容相關性關鍵字可以是使用者定義的符號。

所有執行階段

備註

下列是內容相關性關鍵字清單:

基於可讀性目的,您可能希望限制將內容相關性關鍵字當作使用者定義符號使用。

Windows 執行階段

備註

(沒有這項功能的平台特定備註。)

需求

編譯器選項:/ZW

Common Language Runtime

備註

(沒有這項功能的平台特定備註。)

需求

編譯器選項:/clr

範例

下列程式碼範例顯示,在適當的內容中, property 上下文相關關鍵字可用來定義屬性和變數。

// context_sensitive_keywords.cpp
// compile with: /clr
public ref class C {
   int MyInt;
public:
   C() : MyInt(99) {}

   property int Property_Block {   // context-sensitive keyword
      int get() { return MyInt; }
   }
};

int main() {
   int property = 0;               // variable name
   C ^ MyC = gcnew C();
   property = MyC->Property_Block;
   System::Console::WriteLine(++property);
}
100

另請參閱

適用於.NET 和 UWP 的元件延伸模組