Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get Inconsistent Accessibility error?

Tags:

c#

I'm sorry I'm new to C# and 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;
        }
    }
}

I got this error message:

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

How to fix it? The code compiled fine in Winforms

Thanks in advance.

like image 427
Irwan Avatar asked Jun 28 '26 09:06

Irwan


1 Answers

Probably TPhotoRecord class is private, i.e.

private class TPhotoRecord
{
    //...
}

As far as you return a List<TPhotoRecord> in a public method of a public class:

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

TPhotoRecord cannot be less accessible, i.e. it also should be public.

like image 81
horgh Avatar answered Jun 30 '26 00:06

horgh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!