<p>Greetings,</p>

<p>I need to include a property in my class which is a collection of System.IO.FileInfo objects.  I am not really sure how to do this and how I would add and removed objects from an instance of the the class (I would assume like any other collection).    </p>

<p>Please let me know if I need to add more information.</p>

<p>Thank you</p>

<p>Update: Am I approaching this the wrong way? I have read comments that adding to a collection which is a property is bad practice.  If this is true what is good practice?  I have a bunch of objects I need to store in a collection.  The collection will be added to and removed from before a final action will be taken on it.  Is this a correct approach or am I missing something?</p>

```
File
```
is a static class. So let's assume you meant
```
FileInfo
```
.
There are lots of ways, you can:
Expose a private field
Use Iterators
Expose a private field through a ReadOnlyCollection<>
For example,
```
```
class Foo {
    public IEnumerable<FileInfo> LotsOfFile {
        get {
            for (int i=0; i < 100; i++) {
                yield return new FileInfo("C:\\" + i + ".txt");
            }
        }
    }
    private List<FileInfo> files = new List<FileInfo>();
    public List<FileInfo> MoreFiles {
        get {
            return files;
        }
    }
    public ReadOnlyCollection<FileInfo> MoreFilesReadOnly {
        get {
            return files.AsReadOnly();
        }
    }

}
```
```
With this code, you can easily add to the property
```
MoreFiles
```
:
```
```
Foo f = new Foo();
f.MoreFiles.Add(new FileInfo("foo.txt"));
f.MoreFiles.Add(new FileInfo("BAR.txt"));
f.MoreFiles.Add(new FileInfo("baz.txt"));
Console.WriteLine(f.MoreFiles.Count);
```
```