how to convert this code to C#.net?

Posted by Avicool08 under C# on 3/29/2009 | Views : 1494 | Status : [Member] | Replies : 2
Private Function closeExcel() As Short
Dim count As Short = 0
Dim excelInstance As System.Diagnostics.Process
Dim excelInstances() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("Excel")
For Each excelInstance In excelInstances
Try
excelInstance.Close() '<-- you can use close or kill .. up to you
excelInstance.Kill()
count += 1
Catch ex As Exception
End Try
Next
Return count '<--- this is gonna tell you the # of excel instances closes
End Function




Responses

Posted by: Majith on: 3/29/2009 [Member] Starter

Up
0
Down
Avicool,


Normally you can understand the code functions and try to implement
line by line.

you can refer the below ref :

http://www.developerfusion.com/tools/convert/vb-to-csharp/


Thanks

Avicool08, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Athiraappukuttan on: 5/6/2009 [Member] Starter

Up
0
Down


private short closeExcel()
{
short count = 0;
System.Diagnostics.Process excelInstance = default(System.Diagnostics.Process);
System.Diagnostics.Process[] excelInstances = System.Diagnostics.Process.GetProcessesByName("Excel");
foreach (var excelInstance in excelInstances) {
try {
excelInstance.Close();
//<-- you can use close or kill .. up to you
excelInstance.Kill();
count += 1;
}
catch (Exception ex) {
}
}
return count;
}


Avicool08, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response