views:

100

answers:

2

Possible Duplicate:
Giving a property the same name as its class

In working on a solution where I was struggling to "add" properties to a sealed class, someone pointed out that my naming of a property with the same name as a type was asking for trouble.

Here's a snippet of my code:

class BackupFileInfo : IEquatable<BackupFileInfo>
{
    public FileInfo FileInfo { get; set; }
}

I would have preferred to just inherit FileInfo, but I can't since it's sealed. I'd also like to name it FileInfo (since that's exactly what it is), but want to avoid potential problems later on. I'm trying to avoid silly names like MyFileInfo, but I'm stumped at how best to name the property of type FileInfo.

Is there a best practice for naming properties in this situation?

+1  A: 

This is a duplicate of Giving a property the same name as its class.

This answer intentionally marked as Community Wiki.

Jason
A: 

Sometimes, it's unavoidable.

But in this case, I would name that property 'File'. I never actually have this situation come up in my own projects, but in some others I've worked on I've seen it, and it's not the end of the world (and obviously, it's valid).

Noon Silk