Collections - Lists

Today I need to do exercises on collections.

My solution has 3 projects, one is called "Console", the other is called "Entities" and the new project is called "Business".

My Console projects have a main entry point. The My Entities project contains all of the classes and parent classes for this exercise. My new project called Business has a Clientadm class.

Edit1: This last class has a method that lists instances of a class called "ClientIndividual" inside Entities.

        #region Metodos
        List<ClienteIndividuo> ListarClienteIndividuo = new List<ClienteIndividuo>();
        #endregion

      

The problem is that I see a red line in the new list that says "Is invisible due to security level".

I have a link called "Entities" in my business project. I am using the Entities namespace in my Clientadm class. My ClientIndividual class is just a class and not abstract.

what could it be?

Thank.

Edit2: Also intellisense doesn't work when I want to write any entity classes to the business.

+3


source to share


3 answers


Make sure both classes public

, as well as any attributes you want to get, are declared public

as the default in C # is private

. See example below.

public class FooBar {  
    public List<string> Foo { get; set; }
}

      



MS Docs

+1


source


What you are missing here is your class's access modifier. Access modifiers are keywords that essentially tell the compiler who can "see" (access) your class (hence

Immune to protection level

mistake).



C # access modifiers public

, private

, protected

and internal

. In your case, the class must be public

so that it can be accessed anywhere in the namespace.

You can learn more about this here .

0


source


By default, the security level of a class is internal. Inner classes cannot be accessed outside the library. Please make it public. You can look at access modifiers in C #.

0


source







All Articles