المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to handle a null enum retrieved from web service



C# Programming
08-26-2009, 05:07 PM
I'm trying to retrieve information from a web service. Some of the output parameters are enums and do not have a value in the database. How can I handle a null value in the code? I'm using C# 2008 with the 2.0 framework, if needed I can use a newer framework.

My example code (the actual web service has 9 enums):
Incident_WS.Incident_WSService ws = new Incident_WS.Incident_WSService();
Incident_WS.AuthenticationInfo auth = new Incident_WS.AuthenticationInfo();
auth.userName = "TEST";
auth.password = "WS_TEST";
ws.AuthenticationInfoValue = auth;
string Incident_Number = "INC000000007371";
Incident_WS.StatusType Status;
ws.HelpDesk_Query_Service(Incident_Number, out Status);

From the web service:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:HPD_IncidentInterface_WS")]
public enum StatusType {
New,
Assigned,
[System.Xml.Serialization.XmlEnumAttribute("In Progress")]
InProgress,
Pending,
Resolved,
Closed,
Cancelled,
}

Thanks in advance!