Junior Collections

What is the difference between Add() and AddRange() in a List<T>?

Method Purpose

Add() Adds one item

AddRange

Adds multiple items (collection)

Example:

list.Add(1); // One item

Follow:

list.AddRange(new[] { 2, 3, 4 }); // Multiple

More from C# Programming Tutorial

All questions for this course