Assume my WCF interface declared like that:
[ServiceContract]
public interface IManagementConsole
{
[OperationContract]
ConsoleData GetData(int strategyId);
[DataContract]
public class ConsoleData
{
.....
[DataMember]
public int[] GetConnectionsStats { get; set; }
}
In my program I just assign value:
....
ConsoleData data = new ConsoleData();
....
data.GetConnectionsStats = Program.GetConnectionsStats();
The question is – will that work? Array is actually a pointer? I guess probably pointer will be passed over WCF instead of passing array data?
There is nothing preventing you from passing an array from the client to the server and from the server to the client. Remember that before the actual sending and receiving occurs, data is serialized in order to be transported over the wire. So, no pointers. The data is serialized at the sender’s side and deserialized back on the receiver’s side.
In the example you have shown, there is a service operation which returns an object containing an array of integers. When the client invokes the GetData method, the server will serialize the
ConsoleDatacontract using the configured binding and send it over the wire.On the client side, a copy of this data will be reconstructed by deserializing what is received.