Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Prc = Process.GetProcessById(lvwProcesses.SelectedItems(0).SubItems(3).Text)


Change to C# ???
Posted
Updated 20-Sep-10 22:40pm
v2

1 solution

Just changing the paranthesi to square brackets should do it:

Prc = Process.GetProcessById(Convert.ToInt32(lvwProcesses.SelectedItems[0].SubItems[3].Text));
 
Share this answer
 
v3
Comments
bankkubb 21-Sep-10 4:19am    
it error and show message "The best overloaded method match for 'System.Diagnostics.Process.GetProcessById(int)' has some invalid arguments"
bankkubb 21-Sep-10 4:26am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Johnny J. 21-Sep-10 4:27am    
OK; I assume you were using VB before. It will do an automatic conversion from string to integer if needed (implicit conversion) - C# won't. So you have to explicitly convert it. See my corrected code above.

Note: When doing this you MUST wrap your code in a try/catch to catch errors if the subitem doesn't contain a valid integer!

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