Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted

1 solution

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

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"

C#
private List<string> MyMethod(string s)
   {
   List<string> result = new List<string>();
   ...
   return result;
   }
 
Share this answer
 
v2
Comments
Member 11805607 19-Jul-15 2:58am    
How Declare "MyMethod" please guide me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900