Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - unable to return List

i'm trying to return list of objects from a class and get the following error:

Error 1 Inconsistent accessibility: property type 'System.Collections.Generic.List<EventXmlExtract.Attribute>' is less accessible than property 'EventXmlExtract.EventExtract.AttributeList' C:\Documents and Settings\eyalk\My Documents\Visual Studio 2010\Projects\Blobs\EventExtractDll\EventExtract.cs 14 32 EventExtractDll

my code tries return _attributeList:

public class EventExtract
{
    private string _type;
    private int _type_id;
    private List<Attribute> _attributeList = new List<Attribute>();

    internal List<Attribute> AttributeList
    {
        get { return _attributeList; }
        set { _attributeList = value; }
    }
}

what is the problem ? and how can i retrieve the list ?

like image 502
kaycee Avatar asked Mar 03 '26 04:03

kaycee


1 Answers

Make the class Attribute public or internal.

You can't return a list of objects where the class is private, because then the calling code can't access the objects.

Alternatively make the AttributeList as restricted as the Attribute class, if that is how you want it.

like image 130
Guffa Avatar answered Mar 06 '26 00:03

Guffa



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!