我遇到了问题。我是一名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)'做什么? –