C# cannot convert method to non delegate type

后端 未结 7 1814
猫巷女王i
猫巷女王i 2020-12-08 07:12

I have a class called Pin.

public class Pin
{
    private string title;

    public Pin() { }

    public setTitle(string title) {
        this.         


        
相关标签:
7条回答
  • 2020-12-08 07:37

    As mentioned you need to use obj.getTile()

    But, in this case I think you are looking to use a Property.

    public class Pin
    {
        private string title;
    
        public Pin() { }
    
        public setTitle(string title) {
            this.title = title;
        }
    
        public String Title
        {
            get { return title; }
        }
    }
    

    This will allow you to use

    foreach (Pin obj in ClassListPin.pins)
    {
         string t = obj.Title;
    }
    
    0 讨论(0)
提交回复
热议问题