Project.GetPredecessors

Project.GetPredecessors method

Returns a collection of task links which are predecessors of the specified task.

public TaskLinkCollection GetPredecessors(Task task)
ParameterTypeDescription
taskTaskThe task to get predecessors for.

Return Value

List of predecessors TaskLink.

Examples

Shows how to get predecessors for the specific task.

var project = new Project(DataDir + "GetPredecessorSuccessorTasks.mpp");
var task = project.RootTask.Children.GetById(10);

var predecessors = project.GetPredecessors(task);

// Display names of predecessor and successor tasks
foreach (var predecessor in predecessors)
{
    Console.WriteLine("Predecessor " + predecessor.PredTask.Get(Tsk.Name));
    Console.WriteLine("Successor " + predecessor.SuccTask.Get(Tsk.Name));
}

See Also