gpt4 book ai didi

c# - 当首选名称也是类型名称时如何命名属性

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:04 26 4
gpt4 key购买 nike

<分区>

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

working on a solution where I was struggling to "add" properties to a sealed class , 有人指出 my naming of a property with the same name as a type was asking for trouble .

这是我的代码片段:

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

我宁愿只继承 FileInfo,但我不能,因为它是密封的。我还想将其命名为 FileInfo(因为它确实如此),但希望避免以后出现潜在问题。我试图避免像 MyFileInfo 这样的愚蠢名称,但我对如何最好地命名 FileInfo 类型的属性感到困惑。

在这种情况下是否有命名属性的最佳实践?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com