Hi All,
I'm having a problem with the following code. I get a compiler error
//C:\CSharpStuff\ProcessList\ProcessList\Class1.cs(64): Cannot implicitly convert type 'ProcessListNamespace.structProcessInfo' to 'ProcessListNamespace.ProcessList'
Does anyone know how to make the class properly emumerable?
Thanks,
J
I'm having a problem with the following code. I get a compiler error
//C:\CSharpStuff\ProcessList\ProcessList\Class1.cs(64): Cannot implicitly convert type 'ProcessListNamespace.structProcessInfo' to 'ProcessListNamespace.ProcessList'
Does anyone know how to make the class properly emumerable?
Thanks,
J
Code:
using System;
using System.Collections;
namespace ProcessListNamespace
{
public struct structProcessInfo
{
public string stringName;
public string stringProcessID;
public string stringParentProcessID;
public string stringUserName;
}
class ProcessList
{
private Hashtable ProcessListTable = new Hashtable();
public void AddToList(structProcessInfo ProcessInfo)
{
ProcessListTable.Add(ProcessListTable.Count + 1, ProcessInfo);
}
public void AddToList(string Name, string ProcessID, string PProcessID, string UserName)
{
structProcessInfo temp;
temp.stringName = Name;
temp.stringParentProcessID = PProcessID;
temp.stringUserName = UserName;
}
public void ClearList()
{
ProcessListTable.Clear();
}
public IEnumerator GetEnumerator()
{
return ProcessListTable.GetEnumerator();
}
static void Main(string[] args)
{
structProcessInfo qwe;
qwe.stringName = "Proces4561";
qwe.stringParentProcessID = "1";
qwe.stringProcessID = "345";
qwe.stringUserName = "John";
ProcessList mypl = new ProcessList();
mypl.AddToList(qwe);
foreach(DictionaryEntry myEntry in mypl)
{
Compiler Error--------> mypl = (structProcessInfo)myEntry.Value;
Console.WriteLine("{0} \t {1}", myEntry.Key, qwe.stringName);
}
}
}
}