Method cannot explicitly call operator or accessor

后端 未结 1 1372
余生分开走
余生分开走 2020-12-11 13:25

I added .dll: AxWMPLib and using method get_Ctlcontrols() but it show error like:

AxWMPLib.AxWindowsMediaPlayer.Ctlcontrols.

相关标签:
1条回答
  • 2020-12-11 13:59

    It looks like you are trying to access a property by calling explicitly its get method.

    Try this (notice that get_ and () are missing):

    this.Media.Ctlcontrols.stop();
    

    Here is a small example about how properties work in C# - just to make you understand, this does not pretend to be accurate, so please read something more serious than this :)

    using System;
    
    class Example {
    
        int somePropertyValue;
    
        // this is a property: these are actually two methods, but from your 
        // code you must access this like it was a variable
        public int SomeProperty {
            get { return somePropertyValue; }
            set { somePropertyValue = value; }
        }
    }
    
    class Program {
    
        static void Main(string[] args) {
            Example e = new Example();
    
            // you access properties like this:
            e.SomeProperty = 3; // this calls the set method
            Console.WriteLine(e.SomeProperty); // this calls the get method
    
            // you cannot access properties by calling directly the 
            // generated get_ and set_ methods like you were doing:
            e.set_SomeProperty(3);
            Console.WriteLine(e.get_SomeProperty());
    
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题