加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C#如何调用多个参数

发布时间:2020-12-15 03:57:27 所属栏目:百科 来源:网络整理
导读:我使用下面的代码访问我的表单上的属性,但今天我想写东西到ListView,这需要更多的参数. public string TextValue { set { if (this.Memo.InvokeRequired) { this.Invoke((MethodInvoker)delegate { this.Memo.Text += value + "n"; }); } else { this.Memo.
我使用下面的代码访问我的表单上的属性,但今天我想写东西到ListView,这需要更多的参数.
public string TextValue
    {
        set
        {
            if (this.Memo.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    this.Memo.Text += value + "n";
                });
            }
            else
            {
                this.Memo.Text += value + "n";
            }
        }
    }

如何添加多个参数以及如何使用它们(值,值)?

解决方法

(编辑 – 我觉得我误解了原来的问题)

简单地做一个方法而不是属性:

public void DoSomething(string foo,int bar)
{
    if (this.InvokeRequired) {
        this.Invoke((MethodInvoker)delegate {
            DoSomething(foo,bar);
        });
        return;
    }
    // do something with foo and bar
    this.Text = foo;
    Console.WriteLine(bar);
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读