3
처음으로 Enum을 내 코드에 구현하려고합니다.If 문에서 Enum을 평가하는 방법은 무엇입니까?
public class Application
{
//Properties
public string AppID { get; set; }
public string AppName { get; set; }
public string AppVer { get; set; }
public enum AppInstallType { msi, exe }
public string AppInstallArgs { get; set; }
public string AppInstallerLocation { get; set; }
}
내가 (설치라는 클래스 내에서 메소드가) 다음과 같습니다 : I는 다음과 같습니다 간단한 사용자 정의 클래스를 가지고있는 AppInstallType 문자열의 경우였다
public void Install()
{
if (AppInstallType.exe)
{
ProcessStartInfo procInfo = new ProcessStartInfo("cmd.exe");
procInfo.Arguments = "/c msiexec.exe /i " + AppInstallerLocation + " " + AppInstallArgs; ;
procInfo.WindowStyle = ProcessWindowStyle.Normal;
Process proc = Process.Start(procInfo);
proc.WaitForExit();
}
else
{
ProcessStartInfo procInfo = new ProcessStartInfo("cmd.exe");
procInfo.Arguments = "/c " + AppInstallerLocation + " " + AppInstallArgs;
procInfo.WindowStyle = ProcessWindowStyle.Normal;
Process proc = Process.Start(procInfo);
proc.WaitForExit();
}
}
내 Install 메서드의 시작 부분에있는 문장이 잘 동작했다 (AppInstallType = "msi"). AppInstallType을 Enum으로 변경하면 if 문에 대한 구문을 해결할 수 없습니다.
가능하면 모든 매개 변수를 Install() 메서드에 전달하지 않아도됩니다. 단지 응용 프로그램 개체에 설치() 메서드를 호출하여 응용 프로그램을 설치할 수 좋을 그래서 같은 것이다 :
Application app1 = new Application;
app1.AppInstallType = msi;
app1.Install();
가 어떻게 이것에 대해 갈 것인가? 미리 감사드립니다.