Articles → WCF → Using enums in WCF service

Using enums in WCF service






Prerequisite






[ServiceContract]
public interface IService1 {}




public class Service1: IService1 {}









Steps




[DataContract]
public enum enum_name {
  [EnumMember]
  enum1,
  [EnumMember]
  enum2
}




[ServiceContract]
public interface IService1 {}

[DataContract]
public enum enum_name {
  [EnumMember]
  enum1,
  [EnumMember]
  enum2
}




[ServiceContract]
 public interface IService1 {}

 [DataContract]
 public enum enum_name {
   [EnumMember]
   enum1,
   [EnumMember]
   enum2
 }

 [DataContract]
 public class CompositeType {
   [DataMember]
   public enum_name MyEnum {
     get;
     set;
   }
 }




 [ServiceContract]
 public interface IService1 {
   void DisplayData(CompositeType ct);
 }

 [DataContract]
 public enum enum_name {
   [EnumMember]
   enum1,
   [EnumMember]
   enum2
 }

 [DataContract]
 public class CompositeType {
   [DataMember]
   public enum_name MyEnum {
     get;
     set;
   }
 }




public class Service1: IService1 {
  public void DisplayData(CompositeType ct) {
    throw new NotImplementedException();
  }
}



Back to client application





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, May 19, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250