Inconsistent accessibility problem [duplicate]

孤人 提交于 2019-11-29 15:23:26

Your DB class is not public, so you can't make a public method (or constructor) that takes it as a parameter. (What would callers outside your assembly do?)

You need to either make the DB class public or make the SqlCatalogRepository class (or its constructor) internal.

Which one you do will depend where your types are being used.
If the SqlCatalogRepository is only meant to be used inside your assembly, you should make it internal. (internal means that it's only visible to other types in the same assembly)

If it's meant to be exposed by your assembly to other assemblies, you should make the class public but the constructor internal.

If the DB class itself is meant to be used by types outside your assembly, you should make the DB class itself public.

The type DB is used in a public constructor of a public type. Therefore, the type DB must itself be public.

Check the accessor on the DB class (you dont show it here) it would need to be a Public class in oreder to allow it to be passed in to the overloaded constructor.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!