Hi
I have a FailureMechanism class with 3 members. I also have
an
arraylist FM. I can create FailureMechanism objects and
store them in
the ArrayList, but how can I access one of the stored
members directly.
I want to do:
Console.WriteLine( "fail mech ",
FM[0].FailureMode );
but this does not work. Ideas?
Thanks,
Kim
PS full code below:
using System;
using System.Collections;
public class FailureMechanism {
public FailureMechanism(){
Console.WriteLine("creating a failure
mechanism");
}
~FailureMechanism(){
Console.WriteLine("destroying a failure
mechanism");
}
public string FailureMode;
public string FailureEffects;
public string FailureConsequences;
}
public class SamplesArrayList {
public static void Main() {
ArrayList FM = new ArrayList();
FailureMechanism f= new FailureMechanism();
f.FailureMode = "worn impellor";
f.FailureEffects="flow rate continues to slow to
unacceptable rates";
f.FailureConsequences="surge tank runs dry causing
heater element to
overheat, requiring a 4 hour stoppage";
FM.Add(f);
f=null;
FailureMechanism g;
g=(FailureMechanism)FM[0];
Console.WriteLine( "fail conseq ",
g.FailureConsequences );
Console.WriteLine( "fail mech count",
FM.Count );
Console.WriteLine( "fail mech capacity ",
FM.Capacity );
Console.WriteLine( "fail mech ", FM );
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopers googlegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---
|