vb.net 使类可序列化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14740419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:39:46  来源:igfitidea点击:

make class serializable

vb.netserialization

提问by forX

I search how to made this class serializable for a service (SOAP)

我搜索如何为服务 (SOAP) 使此类可序列化

<Serializable()> _
    Public Class Items

        Inherits StringEnumBase(Of Items)
        Public Sub New(ByVal StrValue As String)
            MyBase.New(StrValue)
        End Sub

        <Description("item 1")> Public Shared ReadOnly ITEM1 As New Items("ValueOfItem1")
        <Description("item 2")> Public Shared ReadOnly ITEM2 As New Items("ValueOfItem2")
        <Description("item 3")> Public Shared ReadOnly ITEM3 As New Items("ValueOfItem3")

    End Class

回答by Oscar

It's ok for the attribute, but it must have a public parameterless constructor.

属性没问题,但它必须有一个公共的无参数构造函数。