列出单个itm传递给方法作为参数 [英] List single itm pass to a method as parameter

查看:81
本文介绍了列出单个itm传递给方法作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用c#语言编写。我想将一个选定的列表项作为参数传递给类方法。在c#

中有任何方法示例:

列出项目:

[0]汽车

[1]追踪

[2]巴士

[3]火车

我有选择总线并想要传递给方法。返回修改后的单词放在列表中。

In c# language. I want to pass a selected list item to a class method as parameter.Is there any method in c#
Example:
list items:
[0]Car
[1]Track
[2]Bus
[3]Train
I have select "Bus" and want to pass to a method. and return modified words is placed in list.

推荐答案

嗯...你的描述非常简单:

Well...your description is of something very simple:
int itemIndex = 2;
List<string> words = MyMethod(listItems[itemIndex]);



所以我不禁想到那不是你真正想要的......但我无法解决你还有什么意思。



如何宣布MyMethod请指导我




So I can't help thinking that isn't what you actually want...but I can't work out what else you mean.

"How Declare "MyMethod" please guide me"

private List<string> MyMethod(string s)
   {
   List<string> result = new List<string>();
   ...
   return result;
   }


这篇关于列出单个itm传递给方法作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆