// add a single item public ImmutableWidgetList Add(Widget widget) { List <Widget> newList = new List <Widget>(_widgets); ImmutableWidgetList result = new ImmutableWidgetList(); result._widgets = newList; return(result); }
// add a range of items. public ImmutableWidgetList AddRange(IEnumerable <Widget> widgets) { List <Widget> newList = new List <Widget>(_widgets); newList.AddRange(widgets); ImmutableWidgetList result = new ImmutableWidgetList(); result._widgets = newList; return(result); }