Learner
Learner

Reputation: 3416

wcf - are enums backward compatible when changing the integer values?

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?

Upvotes: 3

Views: 662

Answers (1)

aKzenT
aKzenT

Reputation: 7915

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

Upvotes: 1

Related Questions