0

I have a struct in my class called RangeName and in one method I am setting up an array of this as follows:

RangeName[] myNames = new RangeName[currWkb.Names.Count];

and later on I want to pass myNames into another method. I have tried:

public void TestRoutine(RangeName[] myNames)

but my code will not build. I get

Inconsistent accessibility: parameter type 'MyTools.clsTest.RangeName[]' is less accessible than method 'MyTools.clsTest.TestRoutine(MyTools.clsTest.RangeName[])'

1
  • Post the code of RangeName, please. Commented Oct 29, 2014 at 18:17

3 Answers 3

4

You need to make your RangeName struct public (at least). Structs and classes are internal by default.Or ofcourse you can make your method less accessible by making it internal.

Sign up to request clarification or add additional context in comments.

1 Comment

"Structs and classes are internal by default": almost. That's true for top-level types (class, struct, interface). But not for nested types. In general, default accessibility is the most restrictive accessibility which still leaves the declared member usable. For nested members, including types, that accessibility is actually private, not internal.
2

When you get an inconsistent accessibility error, it means that a method with higher accessibility (in this case, that would be public) has a parameter type of low accessibility.

You need to ensure that the RangeName struct has public accessibility in its enclosing context. Locate the declaration, and add public in front of struct.

Comments

0

Your RangeName struct is of a lower accessibility than your public TestRoutine which takes RangeName[] as a parameter. If anyone tried to call TestRoutine they would never be able to pass in a parameter as that struct has a very high chance of being inaccessible to the caller.

You can fix this by either making your TestRoutine a lower or equal accessibility to RangeName or increasing RangeName to public.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.