c# - Should data classes which are passed by a webservice be attributes with [Serializable] -


I want to transfer some data squares via the webservice:

  public class MyClass {Public int Int {get; Set; } Public MyClass (int v) {Int = v; } Private MyClass () {}} Public Enum MyEnum {One = 7, two = 13, three = 15} Public Class TestDataClass {Private Int _someInt; Public listing & lt; MyClass & gt; Value {receive; Set; } Public int SomeInt {get {return_someInt + 10; } Set {_someInt = value; }} Public TestDataClass (int someInt) {SomeInt = someInt; Value = new list & lt; MyClass & gt; (); For (Int i = 0; I  

TestData class is the class passed, what should be responsible with the serial?

Thank you, Alex

If you use the old (old) ASMX style webservice Wish: Yes.

When using WCF: No, use [DataContract] instead.

In both cases, you need attributes for the main category and for any embedded type, which is not already serialized or 'known type'.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -