Skip to content

NamedColorCollection Class

A collection of named colors

C#
public class NamedColorCollection : IEnumerable<NamedColor>, IEnumerable

Inheritance object

Implements IEnumerable<NamedColor>, IEnumerable

Creates a new instance with the default colors of White and Black.

C#
public NamedColorCollection()

NamedColorCollection(IEnumerable<NamedColor>)

Section titled “NamedColorCollection(IEnumerable<NamedColor>)”
C#
public NamedColorCollection(IEnumerable<NamedColor> initialCollection)

initialCollection IEnumerable<NamedColor>

The backing dictionary of colors.

C#
public Dictionary<string, NamedColor> Colors { get; set; }

Adds a color to the collection.

C#
public void Add(NamedColor color)

color NamedColor

Clears the collection of colors and adds White and Black colors.

C#
public void LoadDefaults()

Loads a Colors dictionary from a file, and returns a new instance of the NamedColorCollection class with those colors.

C#
public static NamedColorCollection Load(string file)

file string
The file.

NamedColorCollection

FileNotFoundException
Thrown when the file isn’t found.

Saves the Colors dictionary to a file.

C#
public void Save(string file)

file string
The file.

C#
public IEnumerator<NamedColor> GetEnumerator()

IEnumerator<NamedColor>