Chart for .NET > User's Guide > Data Manipulation > Subset Operations > Data Series Subsets 
A data series subset is a set of indexes and(or) ranges of indexes. Each data series subset is represented by an instance of NDataSeriesSubset class. Subsets are returned or required as arguments by various data manipulation functions.
The user can perform the following operations with subsets.
The user adds indexes or ranges of indexes in the subset with the help of the AddIndex and AddRange methods. The following code adds indexes 3, 5, 6, 7 and 8 in a newly created subset.
C# 
Copy Code


NDataSeriesSubset subset = new NDataSeriesSubset();
subset.AddIndex(3);
subset.AddRange(5, 8);

Visual Basic 
Copy Code


Dim subset As NDataSeriesSubset = New NDataSeriesSubset() subset.AddIndex(3) subset.AddRange(5, 8) 
The user can remove indexes from a subset with the help of the RemoveIndex and RemoveRange methods. The following code will remove index 8 and all indexes in the 3  5 range. Thus the subset will contain indexes 6 and 7.
C# 
Copy Code


subset.RemoveIndex(8); subset.RemoveRange(3, 5); 
Visual Basic 
Copy Code


subset.RemoveIndex(8) subset.RemoveRange(3, 5) 
The user can query whether a specific index is contained in the subset with the help of the Contains method. The first call in the following example will return true while the second call will fail.
C# 
Copy Code


bool bContains;
bContains = subset.Contains(6);
bContains = subset.Contains(3);

Visual Basic 
Copy Code


Dim bContains As Boolean bContains = subset.Contains(6) bContains = subset.Contains(3) 
The NDataSeriesSubset class implements the IEnumerable interface. The following examples enumerates all indexes in a subset:
C# 
Copy Code


// enumerate using a foreach statement foreach (int index in subset) { // do something for this index } // enumerate using the standard IEnumerable IEnumerator it = subset.GetEnumerator(); while (it.MoveNext()) { int index = (int)it.Current; // do something for this index } 
Visual Basic 
Copy Code


' enumerate using a foreach statement For Each index As Integer In subset ' do something for this index Next ' enumerate using the standard IEnumerable Dim it As IEnumerator = subset.GetEnumerator() While it.MoveNext() Dim index As Integer = CType(it.Current, Integer) ' do something for this index End While 
The user can perform the following set operations with another subset:
C# 
Copy Code


NDataSeriesSubset paramSubset = new NDataSeriesSubset();
paramSubset.AddIndex(7);
paramSubset.AddIndex(9);
subset.Combine(paramSubset);

Visual Basic 
Copy Code


Dim paramSubset As NDataSeriesSubset = New NDataSeriesSubset() paramSubset.AddIndex(7) paramSubset.AddIndex(9) subset.Combine(paramSubset) 
C# 
Copy Code


subset.Clear(); subset.AddRange(6, 7); subset.Intersect(paramSubset); 
Visual Basic 
Copy Code


subset.Clear() subset.AddRange(6, 7) subset.Intersect(paramSubset) 
Assuming that the subset originally contained 6 and 7, after the operation it will contain indexes 6, 7 and 9;
C# 
Copy Code


subset.Clear(); subset.AddRange(6, 7); subset.Subtract(paramSubset); 
Visual Basic 
Copy Code


subset.Clear() subset.AddRange(6, 7) subset.Subtract(paramSubset) 
Windows forms: All Examples\Data Manipulation\General\Filtering
Windows forms: All Examples\Data Manipulation\General\Evaluating