How to handle collection of data in C#?

119 views Asked by At

I'm using TFS API to get Work Item Collection and then in a DataTable i made Workitem properties like WorkItem Id,Title,Type,State,Assigned To...etc as it's columns. Now in a foreach loop i'm adding the data of WorkItem collection into DataRows. Some of my colleagues saying that this is not a recommended approach and they are advising to Create a Class for WorkItems. nowcan somebody tell me what to do in this scenario.I'm not asking for syntax but for the approach here.I'm a new bee to C#.

1

There are 1 answers

2
Piyush Parashar On

What they probably saying is that you can create a datastructure for your workitem. For example a class like below, which you can manipulate based on your need.

public class MyCustomWorkItem
{
    public string WorkItemID {get; set;}

    public string Description { get; set; }

    // and so on
}

And then you can build a collection of this type of object from the WorkItemCollection received from TFS.