[ vujkev @ 14.02.2009. 11:54 ] @
Code: Public class IDNamePair proerty Name as string Property ID as integer end class Public class Genre inherits IDNamePair end class Public class BackEndClass public _List As IDNamePair() Private _BoxList As New Generic.Dictionary(Of Integer, CheckBox) Public Property SelectedItems() As IDNamePair() Get Return (From b In _BoxList _ Join i In _List On i.ID Equals b.Key _ Where b.Value.Checked = True _ Select GetIDNamePair(i.ID)).ToArray End Get Set(ByVal value As IDNamePair()) For Each b In _BoxList b.Value.Checked = False Next For Each i In value _BoxList.Item(i.ID).Checked = True Next End Set End Property Public Function sigleObject() As IDNamePair Return SelectedItems(0) End Function Private ReadOnly Property GetIDNamePair(ByVal ID As Integer) As IDNamePair Get For Each i As IDNamePair In _List If i.ID = ID Then Return i End If Next Return Nothing End Get End Property end class public class frontEndClass backendclass._list = New Artists.Artist.Genre() {New Artists.Artist.Genre} Dim one As Artists.Artist.Genre = backendclass.sigleObject Dim i() As Artists.Artist.Genre = backendclass.selecteditems Dim o as object = backendclass.selecteditems end class Dosta sam koda obrisao pa ovo ne bi radilo kad se iskompajlira, ali greška je da backendclass.selecteditems vraća IDNamePair array koji ne mogu da konvertujem u Genre array. Kad pogledam sadržaj "O" objekta vidim da se u njemu nalazi lista Genre objekata. Zašto ne mogu da castujem u Genre kad se u njemu nalaze genre objekti? Da li se array nekako drugačije castuje? inače backendclass.sigleObject mi se bez greške castuje u genre. Pozdrav |