none
Is there any way to suppress Inconsistent accessibility

    Question

  • In a form I need to be able to create multiple instance of a class.  I also need to to be able to iterate through them, such as in a List.

    public static List<Class> ListName

    But I get Inconsistent accessibility: field type 'List<Class>' is less accessible than Form.Class  Accessing a single instance of the class through the Form is fine, but its not possible to iterate through multiple instance of a class unless using a List or array perhaps.   This inconsistent accessibility is restrictive to say the least.  Is there a workaround?

    Friday, January 11, 2019 7:28 PM

All replies

  • You can set Class entity as public:public class Class{}. It could be worked. It is because you have public method with some type. But it is inconsistency when you have public method and result entity is not public. You can set method as internal. It means it is accessible from assembly only. 

    You can read about accessors on this link.

    https://docs.microsoft.com/cs-cz/dotnet/csharp/language-reference/keywords/access-modifiers

    Friday, January 11, 2019 8:23 PM
  • Instead of creating the List<> in the Form, I created a public static List<> in the Class itself, call it ClassList, but its not available in the Form, no idea why not.  I did the same for another Class and was able to access its List<> in another Form.  
    Friday, January 11, 2019 9:07 PM
  • I am able to access the List<> through its Class, whereas for another List<> in another Form I was able to access it without using its Class.  Odd!
    Friday, January 11, 2019 9:20 PM
  • I am able to access the List<> through its Class, whereas for another List<> in another Form I was able to access it without using its Class.  Odd!

    Hello,

    In regards to odd, once you read the link Petr B provided it will not be odd, here is the English version.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, January 11, 2019 11:07 PM
    Moderator

  • In regards to odd, once you read the link Petr B provided it will not be odd, here is the English version.


    :) I have czech environment in default so MSDN pages are I have in czech language. I have not noticed that there is cs-cz in link. cs-cz should be replaced by en-US and it is in english. Thank you for correction.
    Saturday, January 12, 2019 8:04 AM