List Info

Thread: arraylist




arraylist
user name
2006-06-15 11:06:30
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 CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

arraylist
user name
2006-06-21 16:50:51
U should use
System.Collections.Generic.List<FailureMechanism>
insted
of ArrayList.
If u use this u do not have to cast the result of the
indexer property.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

arraylist
user name
2006-06-23 09:24:38
When I try:

	List<FailureMechanism> FM = new
List<FailureMechanism>();

I get

[Task:File=/home/kadil/reliability/reliability/Main.cs,
Line=66,
Column=6, Type=Error, Description=Parsing error(CS8025)

What am I doing wrong?

Kim


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

arraylist
user name
2006-06-23 10:28:44
Found it. I am using mono in linux, I cannot find a
System.Collections.Generic.List in mono. It will arrive
soonI am sure.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )