The compiler requires an explicit conversion. For example, you may need to cast an r-value to be the same type as an l-value. Or, you must provide conversion routines to support certain operator overloads.
Process oProcess;
oProcess = Process.GetProcessesByName(sProcessName);
Since GetProcessesByName creates an array of new Process components and associates them with the existing process resources that all share the specified process name, we need to declare oProcess as shown below:
Process[] oProcess;
oProcess = Process.GetProcessesByName(sProcessName);
C# Error Cannot implicitly convert type 'System.Diagnostics.Process[]' to 'System.Diagnostics.Process', .NET Error Cannot implicitly convert type 'System.Diagnostics.Process[]' to 'System.Diagnostics.Process'
No comments:
Post a Comment