[英]Best way to emulate the functionality of Python's “in” keyword in C#?
[英]is there python's as keyword in C#
當我使用python時
我可以使用 as 關鍵字替換庫名
這是一個示例代碼:
import matplotlib.pyplot as plt
plt.rc('font', family = 'Malgun Gothic')
plt.title("title")
plt.plot(a, label = 'maximum degree', color = 'cyan', linestyle=':', marker = 'v')
plt.legend()
plt.show()
根據這段代碼 matplotlib.pyplot 被 'as' 關鍵字替換為 plt
我想用這個關鍵字as
在C#
在 C# 中,“使用別名”; 如果matplotlib.pyplot
是完全限定的 .NET 類型:
using plt = matplotlib.pyplot;
您可以像這樣為 using 命名空間/類設置別名:
using NsJson = Newtonsoft.Json;
public void MyMethod(){
new NsJson.Linq.JObject(); //example
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.