tags:

views:

41

answers:

1

Is there any way to find the size of a data which i am sending to webservice from the client in Csharp dotnet

A: 

Here's a way to find the size of your data when it's serialized to XML, which is what happens when you call a standard SOAP webservice:

var data = GetMyData();
var serializer = new XmlSerializer(data.GetType())
using(var stream = new MemoryStream()) 
{
    serializer.Serialize(stream, data);
    var sizeOfData = stream.Length;
}
Xoltar
-1 for not placing the `MemoryStream` into a `using` block. I'll remove the downvote if you'll fix that.
John Saunders
Added the using block as requested...
Xoltar