Click here to Skip to main content
15,887,397 members
Home / Discussions / C#
   

C#

 
GeneralMessage Closed Pin
8-May-04 7:33
Oshada Athulathmudali8-May-04 7:33 
GeneralRe: Flickering Images Pin
Mazdak8-May-04 8:57
Mazdak8-May-04 8:57 
GeneralRe: Flickering Images Pin
Heath Stewart8-May-04 20:09
protectorHeath Stewart8-May-04 20:09 
GeneralXML Serialization Pin
Diego F.8-May-04 7:26
Diego F.8-May-04 7:26 
GeneralRe: XML Serialization Pin
Mazdak8-May-04 8:36
Mazdak8-May-04 8:36 
GeneralRe: XML Serialization Pin
Diego F.8-May-04 14:44
Diego F.8-May-04 14:44 
Generalaccessing a property through several classes Pin
cristina_tudor8-May-04 6:29
cristina_tudor8-May-04 6:29 
GeneralRe: accessing a property through several classes Pin
ian mariano8-May-04 6:35
ian mariano8-May-04 6:35 
You have to cast the object returned from your Class2 accessor:

((Class3)var2.x[index]).Myprop


To be safe, however, you can't be sure that x at the specified index will have an object instance:

Class3   c = (Class3)var2.x[index];
 
if (c != null)
{
   //   do something with c.Myprop;
}
else
{
   //   do something else, perhaps throw an exception.
}


Alternately, you can use the as keyword:

Class3   c = var2.x[index] as Class3;


Ian Mariano - Bliki | Blog


"We are all wave equations in the information matrix of the universe" - me

GeneralRe: accessing a property through several classes Pin
Meysam Mahfouzi8-May-04 6:46
Meysam Mahfouzi8-May-04 6:46 
GeneralRe: accessing a property through several classes Pin
ian mariano8-May-04 7:23
ian mariano8-May-04 7:23 
GeneralRe: accessing a property through several classes Pin
Meysam Mahfouzi8-May-04 6:38
Meysam Mahfouzi8-May-04 6:38 
GeneralRe: accessing a property through several classes Pin
Jeff Varszegi8-May-04 11:07
professionalJeff Varszegi8-May-04 11:07 
Generalchecklistbox Pin
alsalahy8-May-04 5:43
alsalahy8-May-04 5:43 
GeneralRe: checklistbox Pin
ian mariano8-May-04 6:40
ian mariano8-May-04 6:40 
GeneralClosing an open Task Manager window Pin
Nagendra Kamath K8-May-04 5:00
Nagendra Kamath K8-May-04 5:00 
GeneralRe: Closing an open Task Manager window Pin
ian mariano8-May-04 6:42
ian mariano8-May-04 6:42 
GeneralRe: Closing an open Task Manager window Pin
Heath Stewart8-May-04 20:04
protectorHeath Stewart8-May-04 20:04 
GeneralRe: Closing an open Task Manager window Pin
ian mariano13-May-04 18:42
ian mariano13-May-04 18:42 
GeneralRe: Closing an open Task Manager window Pin
Heath Stewart14-May-04 2:03
protectorHeath Stewart14-May-04 2:03 
GeneralRe: Closing an open Task Manager window Pin
ian mariano14-May-04 3:36
ian mariano14-May-04 3:36 
GeneralUnRegister a Service Process Pin
Nagendra Kamath K8-May-04 4:58
Nagendra Kamath K8-May-04 4:58 
GeneralRe: UnRegister a Service Process Pin
ian mariano13-May-04 18:57
ian mariano13-May-04 18:57 
GeneralUsing outlook to send messages. Pin
mpalle8-May-04 4:35
mpalle8-May-04 4:35 
GeneralRe: Using outlook to send messages. Pin
Heath Stewart8-May-04 20:01
protectorHeath Stewart8-May-04 20:01 
GeneralRe: Using outlook to send messages. Pin
mpalle8-May-04 22:24
mpalle8-May-04 22:24 

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.