---
title: "How to create a copy of the items in a domainupdown C#"  
description: "How to create a copy of the items in a domainupdown C#"  
author: "Anonymous User"  
published: 2013-12-23  
updated: 2013-12-23  
canonical: https://www.mindstick.com/forum/1835/how-to-create-a-copy-of-the-items-in-a-domainupdown-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to create a copy of the items in a domainupdown C#

I was able to copy [decimal](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) [values](https://www.mindstick.com/forum/327/sum-textbox-values) from a [numericUpDown](https://www.mindstick.com/forum/442/validation-on-numericupdown-control-in-c-sharp-dot-net) box fine, but when I try to copy items from a DomainUpDown box with a predefined [collection of items](https://www.mindstick.com/forum/160239/how-to-create-a-razor-view-that-iterates-over-a-collection-of-items-and-displays-them-dynamically) to a new DomainUpDown box I run into problems since I think it may be an [array of strings](https://www.mindstick.com/forum/158840/create-a-rust-program-to-sort-an-array-of-strings-in-lexicographical-order). Here is what I have so far:

```
private DomainUpDown sentNUD2;private void domainUpDown_Click(object sender, EventArgs e){    formPopUpData2 newForm = new formPopUpData2();    this.sentNUD2 = (DomainUpDown)sender;    DomainUpDown copiedNUD = new DomainUpDown();    for (int i = 0; i <= this.sentNUD2.Items.Count-1; i++)    {       
copiedNUD.Items[i] = this.sentNUD2.Items[i];    }
```

My code above is similar to what I did with the numeric boxes, but the addition is the [for loop](https://www.mindstick.com/forum/12568/android-for-loop-not-working-in-main-thread) for the array. I keep getting an out of bounds error. Is there an easier way to copy items from one DomainUpDown to another? Am I on the [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) track? Any help is appreciated.

Thank you.

## Replies

### Reply by Pravesh Singh

Hi Jacob,\

When this code runs, copiedNUD.[Items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) has count of zero. You need to use an Add method on the [collection](https://www.mindstick.com/articles/1718/collections-in-java):

copiedNUD.Items.Add(this.sentNUD2.Items[i]); //fixed naming


---

Original Source: https://www.mindstick.com/forum/1835/how-to-create-a-copy-of-the-items-in-a-domainupdown-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
