Sponsored Ad

Tuesday, April 5, 2011

Inconsistent accessibility: property type 'MyApp.class_type' is less accessible than property 'MyApp.operator_error_class.my_prop' – C# Error

When you try to access a class from another class which have higher accessibility.

using System;

namespace MyApp
{
    public class Inconsistent_accessibility_Class
    {
        public static void Main(string[] args)
        {          
        }

        public class_type my_prop
        {
            get
            {
                return new class_type();
            }
        }

    }
    class class_type
    {
    }
}

How to fix above Error:

add public access in front of class_type class.

using System;

namespace MyApp
{
    public class Inconsistent_accessibility_Class
    {
        public static void Main(string[] args)
        {          
        }

        public class_type my_prop
        {
            get
            {
                return new class_type();
            }
        }

    }
    public class class_type
    {
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates