I have an ASP.NET (.asmx) Web Service project that has a method like:
public int GetData(Data d);
And Data class has properties:
public class Data
{
public int Id { get; set; }
public string Name { get; set; }
}
I want the “Id” property to be seen by client, but not the “Name” property. They all have to be public because inner logic of the application need these properties public.
So how can I set the “Name” property invisible to the client without changing its public accesser, and without making private get, private set?
You can prevent serialisation with the XmlIgnore tag, the proxy classes generated by the client won’t contain the property Name.