C # - cannot return list

I am trying to return a 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 is trying to 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 get the list?

+3
source share
4 answers

Make the class Attributepublic or internal.

You cannot return a list of objects in which the class is private, because then the calling code cannot access the objects.

Alternatively, make it more AttributeListrestricted than a class Attributeif you want to.

+7
source

Your attribute class is missing the required visibility.

change the class definition to

public class Attribute
{

or

internal class Attribute 
{
+2
source

, , private. protected public.

0

?

System; System.Collections.Generic;

...:)

-1

Source: https://habr.com/ru/post/1795219/


All Articles