簡體   English   中英

為什么會出現不一致的可訪問性錯誤?

[英]Why do I get Inconsistent Accessibility error?

對不起,我是C#和WPF的新手。

namespace MyProgram
{
    /// <summary>
    /// Description of TSearchFiles.
    /// </summary>
    public class TSearchFiles
    {
        private TBoolWrapper canceled;

        public TSearchFiles(TBoolWrapper bw)
        {
            canceled = bw;
        }

        public List<TPhotoRecord> GetFilesRecursive(string b)
        {

            List<TPhotoRecord> result = new List<TPhotoRecord>();
            return result;
        }
    }
}

我收到此錯誤消息:

Error   1   Inconsistent accessibility: return type 'System.Collections.Generic.List<MyProgram.TPhotoRecord>' is less accessible than method 'MyProgram.TSearchFiles.GetFilesRecursive(string)'

如何解決? 在Winforms中編譯好的代碼

提前致謝。

TPhotoRecord類可能是private ,即

private class TPhotoRecord
{
    //...
}

就您在公共類的公共方法中返回List<TPhotoRecord>

public class TSearchFiles
{
    //...
    public List<TPhotoRecord> GetFilesRecursive(string b){/*...*/}
}

TPhotoRecord訪問,即它也應該是public.

您的class TPhotoRecord應該是公共的,因為方法public List<TPhotoRecord> GetFilesRecursive(string b)是公共的。

您的TPhotoRecord類是私有的,因此您不能在公共方法的返回類型中談論它。

暫無
暫無

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

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