Inconsistent Accessibility: Parameter type is less accessible than method
Constructor of public
class clients
is public
but it has a parameter of type ACTInterface
that is private
(it is nested in a class?). You can't do that. You need to make ACTInterface
at least as accessible as clients
.
C# Inconsistent accessibility : parameter type is less accessible than method
Make your class public.
public class ClientListener
...
The default access for a class if you do not specify one explicitly is internal. Internal is less accessible than public, therefore you're getting an error.
Parameter is less accessible than method
You have to declare Branch
to be public:
public class Branch {
. . .
}
Inconsistent accessibility: parameter type 'ICourseRepository' is less accessible than method ASP.NET Core MVC
You'll have to set IContactRepository
as public
in the file it is defined.
public interface IContactRepository {
...
}
Inconsistent accessibility error: parameter is less accessible than method
Your ModBoxUpdateInfoForm
constructor is public and requires a parameter of type ModBoxUpdateXml
which is internal. You get this exception because a caller outside of your assembly couldn't call the public ModBoxUpdateInfoForm
constructor, because the caller is not allowed to have knowledge of what a ModBoxUpdateXml
is.
Either make ModBoxUpdateXml
public, or make the ModBoxUpdateInfoForm
constructor internal.
Here is a simple MCVE example:
Causes Compiler Error:
internal class A{}
public class B
{
public B(A a){}
}
Fix:
//Make this public
public class A{}
public class B
{
public B(A a){}
}
Or:
internal class A{}
//Make this internal
internal class B
{
public B(A a){}
}
Or:
internal class A{}
public class B
{
//Make only the constructor internal
internal B(A a){}
}
Inconsistent Accessibility: Parameter type is less accessible than method error
If BanjoState is an enum, I have made some assumptions about the rest of your code and added comments to show what is wrong:
namespace BanjoStore
{
class Program
{
static void Main(string[] args)
{
//Create a Banjo!
var myFirstBanjo = new Banjo("it's my first!", 4, 67, Banjo.BanjoState.Used);
//Oh no! The above line didn't work because I can't access BanjoState!
//I can't used the enum to pass in the value because it's private to the
//Banjo class. THAT is why the error was visible in the constructor.
//Visual Studio knew this would happen!
}
}
class Banjo
{
//These are private by default since there isn't a keyword specified
//and they're inside a class:
string description;
int price;
//This is also private, with the access typed in front so I don't forget:
private int banjoID;
//This enum is private, but it SHOULD be:
//public enum BanjoState
//Even better, it can be internal if only used in this assembly
enum BanjoState
{
Used,
New
}
public Banjo(string inDescription, int inPrice, int inBanjoID,
BanjoState inState)
{
description = inDescription;
price = inPrice;
banjoID = inBanjoID;
BanjoState state = inState;
}
}
}
Tips
- As I mentioned, you need access to the BanjoState enum. The least access necessary to get the job done is best. In this case, that probably means internal. If you're only familiar with public and private, go ahead and make it public. You need this access so that when you make an instance of the Banjo class, you can actually specify a BanjoState for the last parameter.
- An int can't take numbers with a decimal. That might be fine for you, but try out the datatype called decimal.
- Usually people don't add the word 'in' to parameters. That's a style choice, but in the professional world, style choices get important. I would choose words just like the fields your assigning them to:
public Banjo(string description, int price, ...
If you do this, you'll need to get more specific to specify your class fields since the names are the same. You can do that by referring to the class instance with the keyword 'this'.this.description = description;
- You might not want the fields like description, price, etc to be private. If you do, people often name them with an underscore in front:
string _description
If BanjoState is a class in another project which you are referencing, it's in a different assembly from BanjoS and you can't make a constructor with something that is outside your scope.
In this case you'll need to declare the "BanjoState" class to be public. Look at the declaration, and I think you'll not that the class does not have the public keyword. You can't have the parameter (an object of BanjoState type) less accessible than the class using it for construction because then you wouldn't be able to create an instance of the public class.
From the MSDN page on classes:
Classes that you declare directly within a namespace, not nested
within other classes, can be either public or internal. Classes are
internal by default.
Code from the example on the page above (but personalized for you):
class BanjoState //This class is internal, not public!
{
// Methods, properties, fields, events, delegates
// and nested classes go here.
}
Related Topics
Best Timer For Using in a Windows Service
What's the Difference Between an Object Initializer and a Constructor
Compare Two List≪T≫ Objects For Equality, Ignoring Order
C# Constructor Execution Order
Find a Private Field With Reflection
How to Prevent And/Or Handle a Stackoverflowexception
Mvc Form Not Able to Post List of Objects
Why Catch and Rethrow an Exception in C#
Dynamically Replace the Contents of a C# Method
Linq-To-Entities Join VS Groupjoin
How to Add a Timer to a C# Console Application
Contains()' Workaround Using Linq to Entities
How to Get the List of Open File Handles by Process in C#
Converting String to Byte Array in C#
C# Getting the Path of %Appdata%
Using Transactions or Savechanges(False) and Acceptallchanges()