Click here to Skip to main content
15,906,645 members
Home / Discussions / C#
   

C#

 
AnswerRe: role of substitution Pin
Ravi Sant14-Apr-11 1:05
Ravi Sant14-Apr-11 1:05 
QuestionFree/Open Source Library to Generate Barcodes Pin
Rafferty Uy11-May-10 21:36
Rafferty Uy11-May-10 21:36 
AnswerRe: Free/Open Source Library to Generate Barcodes Pin
Peace ON11-May-10 21:50
Peace ON11-May-10 21:50 
GeneralRe: Free/Open Source Library to Generate Barcodes Pin
Rafferty Uy11-May-10 22:44
Rafferty Uy11-May-10 22:44 
AnswerRe: Free/Open Source Library to Generate Barcodes Pin
Luc Pattyn12-May-10 1:58
sitebuilderLuc Pattyn12-May-10 1:58 
Questionproblem while using delegates in c# Pin
sindhumahe11-May-10 19:42
sindhumahe11-May-10 19:42 
AnswerRe: problem while using delegates in c# Pin
DaveyM6911-May-10 21:33
professionalDaveyM6911-May-10 21:33 
AnswerRe: problem while using delegates in c# Pin
Luc Pattyn12-May-10 2:00
sitebuilderLuc Pattyn12-May-10 2:00 
AnswerRe: problem while using delegates in c# Pin
Hristo-Bojilov12-May-10 3:10
Hristo-Bojilov12-May-10 3:10 
Questionhow to create cab file from setup exe file using cabsdk Pin
NarVish11-May-10 19:37
NarVish11-May-10 19:37 
AnswerRe: how to create cab file from setup exe file using cabsdk Pin
Abhinav S11-May-10 20:20
Abhinav S11-May-10 20:20 
QuestionHow to encrypt data in mySQL using C# Pin
MissNano11-May-10 18:34
MissNano11-May-10 18:34 
AnswerRe: How to encrypt data in mySQL using C# Pin
Peace ON11-May-10 22:14
Peace ON11-May-10 22:14 
QuestionDate Pickers with Checkboxes and Modified Rows Pin
gmhanna11-May-10 17:44
gmhanna11-May-10 17:44 
AnswerRe: Date Pickers with Checkboxes and Modified Rows Pin
Stanciu Vlad11-May-10 19:27
Stanciu Vlad11-May-10 19:27 
QuestionWhere to get started Pin
crosson11-May-10 17:09
crosson11-May-10 17:09 
AnswerRe: Where to get started Pin
Peace ON11-May-10 21:58
Peace ON11-May-10 21:58 
AnswerRe: Where to get started Pin
Richard MacCutchan11-May-10 22:27
mveRichard MacCutchan11-May-10 22:27 
AnswerRe: Where to get started Pin
crosson12-May-10 10:51
crosson12-May-10 10:51 
AnswerRe: Where to get started Pin
Ravi Sant14-Apr-11 1:22
Ravi Sant14-Apr-11 1:22 
QuestionSerialization Question Pin
Kevin Marois11-May-10 11:14
professionalKevin Marois11-May-10 11:14 
AnswerRe: Serialization Question Pin
William Winner11-May-10 11:40
William Winner11-May-10 11:40 
I can give you an example from a project I was working on...though I'll warn you that it's in VB, not C#. But it should demonstrate the concepts.

I have a base class:
VB
<Serializable()> _
Public MustInherit Class BaseClass
    Private _Name As String
    Private _UniqueName As String

    <NonSerialized(), XmlIgnore()> _
    Private _worker As System.ComponentModel.BackgroundWorker

    Public Sub New(ByVal Name As String, ByVal UniqueName As String, _
                   Optional ByRef myWorker As System.ComponentModel.BackgroundWorker = Nothing)
        _Name = Name
        _UniqueName = UniqueName
        _worker = myWorker
    End Sub

    Public Sub New()
        _worker = Nothing
    End Sub

    Public Sub New(ByRef myWorker As System.ComponentModel.BackgroundWorker)
        _worker = myWorker
    End Sub

    <XmlElement("Name")> _
    Public Property Name() As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property

    <XmlElement("UniqueName")> _
    Public Property UniqueName() As String
        Get
            Return _UniqueName
        End Get
        Set(ByVal value As String)
            _UniqueName = value
        End Set
    End Property

    Public Sub PerformStep()
        If _worker IsNot Nothing Then
            _worker.ReportProgress(50)
        End If
    End Sub

    Public ReadOnly Property Worker() As System.ComponentModel.BackgroundWorker
        Get
            Return _worker
        End Get
    End Property
End Class


Then, I inherit that class from another class:
VB
<Serializable()> _
Public Class Member
    Inherits BaseClass

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal Name As String, ByVal UniqueName As String, _
                   Optional ByRef myWorker As System.ComponentModel.BackgroundWorker = Nothing)
        MyBase.New(Name, UniqueName, myWorker)
    End Sub
End Class


And as an FYI, here was another class that had a collection of class Member:
VB
<Serializable()> _
Public Class Members
    Inherits Loads

    Private _members() As Member

    Public Sub New()
        ReDim _members(-1)
    End Sub

    Public Sub New(ByRef myWorker As System.ComponentModel.BackgroundWorker)
    End Sub

    Public Sub New(ByRef Members As ADOMD.Members, _
                   Optional ByRef myWorker As System.ComponentModel.BackgroundWorker = Nothing)
    End Sub

    Public Sub LoadMembers(ByRef Members As ADOMD.Members)
    End Sub

    <XmlElement("Member")> _
    Public Property Members() As Member()
        Get
            Return _members
        End Get
        Set(ByVal value As Member())
            _members = value
        End Set
    End Property

    Public ReadOnly Property Count() As Long
        Get
            Return UBound(_members) + 1
        End Get
    End Property

    Public Overloads ReadOnly Property Items() As Member()
        Get
            Return _members
        End Get
    End Property

    Public Overloads ReadOnly Property Items(ByVal Index As Long) As Member
        Get
            If Index <= UBound(_members) Then
                Return _members(Index)
            Else
                Return Nothing
            End If
        End Get
    End Property

    Public Overloads ReadOnly Property Items(ByVal Name As String) As Member
        Get
            For i = 0 To UBound(_members)
                If _members(i).Name = Name Then
                    Return _members(i)
                End If
            Next

            Return Nothing
        End Get
    End Property

End Class


It worked perfectly for me and deserialized perfectly.
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 11:55
professionalKevin Marois11-May-10 11:55 
GeneralRe: Serialization Question Pin
William Winner11-May-10 12:07
William Winner11-May-10 12:07 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 12:15
professionalKevin Marois11-May-10 12:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.