JackTheRipper JackTheRipper - 1 year ago 132
C# Question

Cannot Access with an Instance Reference

While I can do this:


I can't do this:

var process = new System.Diagnostics.Process();

Error: Member 'System.Diagnostics.Process.Start(string)' cannot be accessed with an instance reference; qualify it with a type name instead.

What is the reason behind this? Can anyone please explain?

Thanks in advance!

Answer Source

it's a static method. You can't use it off an instance of Process:

public static Process Start(string fileName)

Use the empty Start() method, that is designed to work off an instance:

Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download