Question

Given the following enum which is used only as output in a wcf service:

[DataContract] 
public enum Role
{
   [EnumMember]
   Undefined = 0,

   [EnumMember]
   Admin,

   [EnumMember] 
   Supervisor,

   [EnumMember]
   User
}

...is it true that I could change the integer values without breaking compatibility with existing clients? Like this:

[DataContract] 
public enum Role
{
   [EnumMember]
   Undefined = 0,

   [EnumMember]
   Admin = 10,

   [EnumMember] 
   Supervisor = 20,

   [EnumMember]
   User = 30
}

AFAIK enumerations are transferred through wcf (soap, to be more exact) as strings. Is there something which I miss here?

Was it helpful?

Solution

WCF does preserve the numerical values in a data contract when using a WCF client and using DataContract and the DataContractSerializer.

If this is not the case, only the member name will be transferred.

Source: http://msdn.microsoft.com/en-us/library/aa347875.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top