Groups | Blog | Home
all groups > dotnet general > april 2005 >

dotnet general : nested listst


Van den Houten Willy
4/7/2005 11:23:03 PM
Hello,

Can anyone help me to get this code up and running ?
It's a task about nested lists, and I don't understand it.

Module Client
Sub Main()
Dim myProcess1 As New Process("process1")
PrintProcessData(myProcess1)

Dim myTask1 As New Task("task1")
myProcess1.AddTask(myTask1)
PrintProcessData(myProcess1)

myProcess1.AddTask(New Task("task2"))
PrintProcessData(myProcess1)

myProcess1.AddTask(New Task("task3"))
PrintProcessData(myProcess1)

Dim myProcess2 As New Process("process2")
myProcess2.AddTasks(New Task() {New Task("task4"), myTask1, New
Task("task5")})
PrintProcessData(myProcess2)

myTask1.Name = "task1b"
PrintProcessData(myProcess1)
PrintProcessData(myProcess2)

myProcess2.AddTasks(myProcess1)
PrintProcessData(myProcess2)

Console.ReadLine()
End Sub
Sub PrintProcessData(ByVal process As Process)
Console.WriteLine("PROCESS: " & process.Name)
Console.WriteLine("INHOUD:")
Console.WriteLine(process.ToString())
Console.WriteLine("AANTAL-ELEMENTEN: " & process.Count())
Dim firstTask As Task = process.FirstTask()
If Not firstTask Is Nothing Then
Console.WriteLine("FIRST-TASK: " & process.FirstTask().Name)
Else
Console.WriteLine("FIRST-TASK: -")
End If
Dim lastTask As Task = process.LastTask()
If Not lastTask Is Nothing Then
Console.WriteLine("LAST-TASK: " & process.LastTask().Name)
Else
Console.WriteLine("LAST-TASK: -")
End If

Console.WriteLine("********************************************************************************")
End Sub
End Module


Cor Ligthert
4/8/2005 12:00:00 AM
Willy,

A strange question, why do you ask this, do you want to use it for some
reason or did you find it on internet and it does not run?

Cor

Van den Houten Willy
4/8/2005 1:55:03 AM
Hi Cor,

It's a task for school, but I don't understand it...
I think this shouldn't be a task...

Thanks

Willy

[quoted text, click to view]
Nick Malik [Microsoft]
4/11/2005 8:32:39 AM
Hello Willy,

If this is your code, it isn't clear what you are attempting to accomplish
with it.

Is PrintProcessData() supposed to iterate through the array of tasks in each
Process? It doesn't. Consider using a For Each loop.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
[quoted text, click to view]

AddThis Social Bookmark Button