簡體   English   中英

接口列表錯誤“未實現接口成員”

[英]interface List Error “does not implement interface member”

我正在擴展我之前的問題,該問題已解決。 如何動態調用方法的 Class 名稱?

interface IVideoCodec成功地與void方法一起使用,但它不適用於List

VP8 Class給出錯誤'VP8' does not implement interface member 'Controls.IVideoCodec.test'

VP8 類錯誤


文件:VideoControls.cs
 namespace Controls.Video { public class Controls { private static Dictionary<string, IVideoCodec> _vCodecClass; private static void InitializeCodecs() { _vCodecClass = new Dictionary<string, IVideoCodec> { { "VP8", new Codec.VP8() }, { "VP9", new Codec.VP9() }, { "x264", new Codec.x264() }, { "x265", new Codec.x265() } }; } public interface IVideoCodec { List<string> test { get; set; } // doesn't work //void Example(); // works } public static void SetControls(string codec_SelectedItem) { InitializeCodecs(); List<string> example = _vCodecClass[codec_SelectedItem].test; // equal to Codec.VP8.test //_vCodecClass[codec_SelectedItem].Example(); // equal to Codec.VP8.Example() // works } } }
文件:VP8.cs
 namespace Controls.Video.Codec { public class VP8: Controls.IVideoCodec // <-- Gives Error { public List<string> test = new List<string>() { "1", "2", "3" }; public void Example() { //... } } }

在您的界面中您聲明了一個屬性,但在 VP8 中您有一個字段。 將其更改為

public class VP8 : Controls.IVideoCodec // <-- Gives Error
{
    public List<string> test  {get; set;} = new List<string>()
    {
        "1",
        "2",
        "3"
    };

    public void Example()
    {
        //...
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM