Error 1 Inconsistent accessibility: return type is less accessible than method

前端 未结 4 1731
谎友^
谎友^ 2020-12-20 11:12

When I\'m building, VS show error. This is my code:

public Composite buildComposite(ComboBox subs, ComboBox bas)
{
    int count = 0;
    Composite a = new C         


        
4条回答
  •  难免孤独
    2020-12-20 11:53

    Your Composite class is not public. You can't return a non-public type from a public method.

    If you don't specify an accessibility for a non-nested class then internal is used by default. Add public to your Composite class definition:

    public class Composite
    {
        ...
    

    Alternatively, if buildComposite doesn't need to be public (meaning it's only used internally by the form), then you could make the method private as well:

    private Composite buildComposite(ComboBox subs, ComboBox bas)
    {
        ....
    

提交回复
热议问题