How to name a property when the preferred name is also a type name

Possible duplicate:
Providing a property with the same name as its class

In working on a solution where I was trying to β€œadd” properties to a private class , someone pointed out that my property name with the same name as the type posed problems .

Here is a snippet of my code:

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

I would rather just inherit FileInfo , but I cannot, as it is sealed. I would also like to call it FileInfo (since that’s exactly what it is), but you want to avoid potential problems later. I am trying to avoid stupid names like MyFileInfo , but I don’t understand what is the best way to name a property like FileInfo .

Is there a best practice for naming in this situation?

+2
c # properties naming-conventions
source share
1 answer

Sometimes this is inevitable.

But in this case, I would call this property β€œFile”. I have never encountered this situation in my own projects, but in some others I worked on, I saw this, and this is not the end of the world (and, obviously, this is really so).

0
source share

All Articles