Inconsistent availability: the base class is less accessible than the class

I have the code below and I'm trying to do some inheritance, but when I try to run this code, it gives me an error:

Inconsistent Accessability: Base Class is less accessible than class

The code:

class Program
{
    static void Main()
    {

        FoodProducts Test = new FoodProducts();

        Test.Limit();



    }
}

public class FoodProducts : Products
{
    public void FoodProduct()
    {
        Console.WriteLine("This is food product");
    }

    public void Limit()
    {
        Console.WriteLine("This is an Attribute of a Product");
    }

}

Can anyone help me?

+5
source share
8 answers

What line is the error, and what is the specific text of the error? Also, where is the definition Products?

You probably get CS0060 : “Inconsistent availability: the base class“ class1 ”is less accessible than the class“ class2. ”Thus, I accept your Productsclass is not marked as public.

, public (internal, ), public.

+12

- , , , :

public class Foo : Base<Bar> {} <-- Inconsistent accessibility

public class Base<T> {}

, , :

internal class Bar {}
+5

, Products . public Products.

- :

class Products {
 ...
}

# Products .

+3

public , .

+2

, , , , . , .

0
public class Products

( ), .

0

, , .

0

, , , .

0
source

All Articles