我有一個模型類,每個屬性都映射到一個模型類。 考慮模型類 「Contact」 public class Contact
{
public Profile profileInfo { get; set; }
public bool isActive { get; set; }
}
public class Profile
{
public string Fir
說你有一個像這樣 public class Foo
{
public int Bar { get; set; } = 42;
}
一類。如果你試圖將財產傳給作爲ref參數編譯器會發出錯誤 CS0206屬性或分度器可能不作爲輸出或參考 參數 這是可以理解的,因爲在普拉克在上面的例子中將屬性編號爲get_Bar()和set_Bar()方法。但是,如果您在屬性上使用增量運算符,如 va
根據定義,ref關鍵字必須在傳遞之前進行初始化。而out參數必須在從函數返回之前進行初始化。 下面是我的代碼片段。 public void TestRef(ref string n)
{
}
public void TestOut(out string n)
{
n = "Hello"; //if I don't initialize, I