Click here to Skip to main content
15,897,148 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Serialization Question Pin
William Winner11-May-10 12:43
William Winner11-May-10 12:43 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 12:54
professionalKevin Marois11-May-10 12:54 
GeneralRe: Serialization Question Pin
William Winner12-May-10 6:01
William Winner12-May-10 6:01 
GeneralRe: Serialization Question Pin
Kevin Marois12-May-10 6:39
professionalKevin Marois12-May-10 6:39 
AnswerRe: Serialization Question Pin
William Winner11-May-10 12:44
William Winner11-May-10 12:44 
Questioninternal keyword, InternalsAvailableTo Pin
Ryan Minor11-May-10 8:13
Ryan Minor11-May-10 8:13 
AnswerRe: internal keyword, InternalsAvailableTo Pin
Paulo Zemek11-May-10 9:41
Paulo Zemek11-May-10 9:41 
QuestionHow do I change service startup type Pin
ziopino7011-May-10 6:25
ziopino7011-May-10 6:25 
AnswerRe: How do I change service startup type Pin
#realJSOP11-May-10 6:30
professional#realJSOP11-May-10 6:30 
GeneralRe: How do I change service startup type Pin
ziopino7011-May-10 6:59
ziopino7011-May-10 6:59 
GeneralRe: How do I change service startup type Pin
PIEBALDconsult11-May-10 7:50
mvePIEBALDconsult11-May-10 7:50 
GeneralRe: How do I change service startup type Pin
Luc Pattyn11-May-10 7:54
sitebuilderLuc Pattyn11-May-10 7:54 
AnswerRe: How do I change service startup type Pin
Dimitri Witkowski11-May-10 10:01
Dimitri Witkowski11-May-10 10:01 
GeneralRe: How do I change service startup type Pin
Sunil G11-May-10 22:27
Sunil G11-May-10 22:27 

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.