-
Notifications
You must be signed in to change notification settings - Fork 0
HashSet Extensions
Andrzej Kebab edited this page Jan 21, 2024
·
1 revision
Adds a range of elements to the end of the HashSet.
using UtilityLibrary.Core;
using System.Collections.Generic;
HashSet<int> numbers = new HashSet<int> { 1, 2, 3 };
IEnumerable<int> additionalNumbers = new List<int> { 4, 5, 6 };
numbers.AddRange(additionalNumbers);
// Result: numbers = { 1, 2, 3, 4, 5, 6 }In this example, the AddRange method is used to add the elements from the additionalNumbers collection to the existing HashSet<int>. After calling the method, the numbers HashSet contains all the elements from both the original HashSet and the additional collection.