我遇到了問題。我是一名VB.net程序員,我正在努力學習C#。在我已經完成的很多VB項目中,我總是使用一個viewModelBase
類,在那裏我可以通過我的項目通知我的屬性,當我嘗試將代碼從vb轉換爲C#時,我得到一個method name expected
就行了:if (TypeDescriptor.GetProperties(this)(propertyName) == null)
c#方法名稱預計INotifypropertyChanged
[Conditional("DEBUG"), DebuggerStepThrough()]
public void VerifyPropertyName(string propertyName)
{
if (TypeDescriptor.GetProperties(this)(propertyName) == null)
{
string msg = "Invalid property name: " + propertyName;
if (this.ThrowOnInvalidPropertyName)
{
throw new Exception(msg);
}
else
{
Debug.Fail(msg);
}
}
}
我真的找不到任何解決方案!任何幫助?
謝謝
雙括號似乎真的了。你只能調用一個函數,所以你應該只有一個函數。也許你打算使用逗號'GetProperties(this,propertyName)'? – BradleyDotNET
@BradleyDotNET'TypeDescriptor.GetProperties()'沒有重載,它需要一個'object'和一個'string'。 –
你期望* TypeDescriptor.GetProperties(this)(propertyName)'做什麼? –