c# method name expected INotifypropertyChanged

I'm running into a problem. I'm a VB.net programmer and I'm trying to learn C#. On many VB projects that I have done I've always used a viewModelBase class where I can notify my properties over my project, when I try to convert the code from vb to C# I'm getting a method name expected on the line: if (TypeDescriptor.GetProperties(this)(propertyName) == null)

[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);
            }
        }
    }

I really can't find any solution for this! Any help?

Thank you

Jon Skeet
people
quotationmark

It sounds like you're just missing the fact that indexer syntax in C# is [key]. I suspect you want:

if (TypeDescriptor.GetProperties(this)[propertyName] == null)

That's first calling the GetProperties method, to find the PropertyDescriptorCollection of all the properties of this... then it's using the indexer of PropertyDescriptorCollection to access a specific property by name.

people

See more on this question at Stackoverflow