C#如何调用多个参数

前端之家收集整理的这篇文章主要介绍了C#如何调用多个参数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用下面的代码访问我的表单上的属性,但今天我想写东西到ListView,这需要更多的参数.
  1. public string TextValue
  2. {
  3. set
  4. {
  5. if (this.Memo.Invokerequired)
  6. {
  7. this.Invoke((MethodInvoker)delegate
  8. {
  9. this.Memo.Text += value + "\n";
  10. });
  11. }
  12. else
  13. {
  14. this.Memo.Text += value + "\n";
  15. }
  16. }
  17. }

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

解决方法

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

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

  1. public void DoSomething(string foo,int bar)
  2. {
  3. if (this.Invokerequired) {
  4. this.Invoke((MethodInvoker)delegate {
  5. DoSomething(foo,bar);
  6. });
  7. return;
  8. }
  9. // do something with foo and bar
  10. this.Text = foo;
  11. Console.WriteLine(bar);
  12. }

猜你在找的C#相关文章