Articles → WCF → List converted to array while consuming WCF service

List converted to array while consuming WCF service









[ServiceContract]
public interface IService1
{

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        List<CompositeType> GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
}


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
 [DataContract]
 public class CompositeType
 {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
}






public class Service1 : IService1
{
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public List<CompositeType> GetDataUsingDataContract(CompositeType composite)
        {
            return new List<CompositeType>();
        }
}





Click to Enlarge


Solution





Click to Enlarge




Click to Enlarge




Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, May 15, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250