This article explains how to expose enums used in WCF Service to the clients who consume our Service.
Create a WCF Service and create an enum inside it.
- [DataContract]
- public enum Status
- {
- [EnumMember]
- Open,
- [EnumMember]
- InProgress,
- [EnumMember]
- Done,
- [EnumMember]
- Close
- }
We just need to make sure that we use that enum in our WCF Service, otherwise you will not find it on the client side. Below we have defined GetDataStatus as an operation contract, which takes our Status enum as a parameter.
- [ServiceContract]
- public interface IService1
- {
- [OperationContract]
- string GetDataStatus(Status state);
- }
- public class Service1 : IService1
- {
- public string GetDataStatus(Status state)
- {
- if (state == Status.Open)
- {
- return "Status Open";
- }
- if (state == Status.Done)
- {
- return "Status Done";
- }
- return string.Empty;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client();
- Console.WriteLine(sc.GetDataStatus(ServiceReference1.Status.Open));
- Console.ReadKey();
- }
- }
Thanks for reading and you can find the source code attached, which is used in this article.

Join the conversation! Your thoughts help the community grow.