参数类型的可访问性不如方法

参数类型的可访问性不如方法

本文介绍了不一致的可访问性:参数类型的可访问性不如方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在两个表单之间传递一个对象(基本上是对当前登录用户的引用).目前,我在登录表单中有一些类似的内容:

I'm trying to pass an object (a reference to the currently logged on user, basically) between two forms. At the moment, I have something along these lines in the login form:

private ACTInterface oActInterface;

public void button1_Click(object sender, EventArgs e)
    {
        oActInterface = new ACTInterface(@"\actserverDatabasePremier.pad",this.textUser.Text,this.textPass.Text);

        if (oActInterface.checkLoggedIn())
        {
            //user has authed against ACT, so we can carry on
            clients oClientForm = new clients(oActInterface);
            this.Hide();
            oClientForm.Show();
        }
        else...

在下一个表单(客户)中,我有:

on the next form (clients), I have:

public partial class clients : Form
{
    private ACTInterface oActInt {get; set;}

    public clients(ACTInterface _oActInt)

...这导致我得到:

Error   1   Inconsistent accessibility:
parameter type 'support.ACTInterface' is less accessible than method
'support.clients.clients(support.ACTInterface)'
c:work
etackupsupportsupportclients.cs   20  16  support

我真的不明白问题是什么 - 这两个字段都是私有的,并且可以通过表单中的相关公共方法访问.谷歌搜索并没有真正的帮助,因为它只是指出一个元素是公开的,另一个是私有的,而这里的情况并非如此.

I don't really understand what the problem is - both fields are private, and accessed by the relevant public method from the form. Googling doesn't really help, as it just points towards one element being public and the other private, which isn't the case here.

有人帮忙吗?

推荐答案

public 类的构造函数 clientspublic 但它有一个参数ACTInterface 类型是 private (它嵌套在一个类中?).你不能那样做.您需要使 ACTInterface 至少与 clients 一样可访问.

Constructor of public class clients is public but it has a parameter of type ACTInterface that is private (it is nested in a class?). You can't do that. You need to make ACTInterface at least as accessible as clients.

这篇关于不一致的可访问性:参数类型的可访问性不如方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 05:49