user1538072
user1538072

Reputation: 1

access an array of type class which is internal in a public class

I have an internal class

namespace commonNamespace
{
    internal class A{}
}

i have another public class within the same assembly

public class B{}

I want to declare an array of type A in classB. ex:

namespace commonNamespace
{
    public class B
    {
        A[] array;
    }
}

I am getting inconsistent accessibility Level error message.Please let me know how can i do this.

Upvotes: 0

Views: 112

Answers (2)

Klark
Klark

Reputation: 8280

Just add access modifier to the field Array:

public class B
{
   internal A[] array;
}

This is the Access Modifiers hierarchy:

 public > protected > internal > internal protected > private

So just choose anything below protected and you will be fine.

Upvotes: 1

Lukazoid
Lukazoid

Reputation: 19416

You must have a public/protected field or property in B exposing some instance(s) of type A. Mark that as internal and you should be good to go.

Upvotes: 2

Related Questions