Tag: 命名

这种模式叫什么? 软锁?

以下是我必须编写的一些代码,主要是与UI内容结合使用,并且总是会出现可能意外结束无限循环的事件。 public class MyClass { public event EventHandler MyEvent; private bool IsHandlingEvent = false; public MyClass() { MyEvent += new EventHandler(MyClass_MyEvent); } void MyClass_MyEvent(object sender, EventArgs e) { if (IsHandlingEvent) { return; } IsHandlingEvent = true; { // Code goes here that handles the event, possibly invoking ‘MyEvent’ again. // IsHandlingEvent flag is used to […]

为什么字符串和对象的别名是小写的?

下面是C#中的别名列表(C#中字符串和字符串的区别是什么? ): object: System.Object string: System.String bool: System.Boolean byte: System.Byte sbyte: System.SByte short: System.Int16 ushort: System.UInt16 int: System.Int32 uint: System.UInt32 long: System.Int64 ulong: System.UInt64 float: System.Single double: System.Double decimal: System.Decimal char: System.Char 我可以通过char看到bool是小写别名,因为它们是原始类型。 为什么对象和字符串没有大写,因为它们是复杂的类型? 这是开发人员的疏忽,还是他们必须小写的必要原因? 或者这是一个自以为是的问题? 你最终得到了像string.Format()而不是String.Format() ,它看起来很时髦,让我觉得string是一个变量。

通用基类包装嵌套generics类以减少类型参数规范:此模式是否有名称?

好的问题标题远非不言自明。 我看到自己经常这样做: 从这个答案 : public static class Equality { public static IEqualityComparer CreateComparer(Func keySelector) { return new KeyEqualityComparer(keySelector); } class KeyEqualityComparer : IEqualityComparer { readonly Func keySelector; public KeyEqualityComparer(Func keySelector) { this.keySelector = keySelector; } public bool Equals(T x, T y) { —- } public int GetHashCode(T obj) { …. } } } 我做了什么:我必须调用一个实现细节KeyEqualityComparer : […]

我应该为DateTime属性命名什么?

如果我有一个存储DateTime的类: class LogEntry { readonly DateTime dateTime; public LogEntry(DateTime dateTime) { this.dateTime = dateTime; } public DateTime ????? { get { return dateTime; } } } 我该怎么命名DateTime属性? 或者我应该将属性拆分为2个属性:1)日期2)时间? 编辑:我正在寻找一个属性名称,提供推断,它的值既是日期又是时间,而不是特定于日志条目的属性(例如,DateCreated不提供任何推断,它也分享创建条目的时间反之亦然)。

是否有.NET函数来validation类名?

我正在使用CodeDom根据用户值生成动态代码。 其中一个值控制着我正在生成的类的名称。 我知道我可以根据有关使用正则表达式的有效类名的语言规则对名称进行消毒,但我想知道框架中是否有一个特定的方法来validation和/或消毒类名。

LINQ:为什么称它为“理解语法”

为什么以下LINQ语法 (有时称为“查询”语法)称为“理解”语法? 什么被理解(肯定是错的)? 或者,什么是全面的代表(也许我现在正走在正确的轨道上)?

为类实例提供变量的名称

如何为类实例提供现有变量的名称。 我想这个string hex = “BF43F”; Zeugh hex = new Zeugh(); string hex = “BF43F”; Zeugh hex = new Zeugh(); 但它错了。 我想创建一个具有Zeugh类属性的对象BF43F。

什么是SUT,它来自哪里?

我看到很多人都在谈论SUT这个术语,但不明白为什么他们会使用这个术语。 SUT是你想要测试的吗? 这个术语来自哪里,它意味着什么? 例如,在这个测试中,我的SUT是什么? [TestMethod] public void UsersAction_should_return_IndexAction() { const long id = 1; UsersViewModel viewModel = new UsersViewModel() { SelectedUsers = new long[] { 1, 2, 3, 4 } }; ActionResult result = _controller.Users(id, viewModel); result.AssertActionRedirect().ToAction(“Index”); }

DataGridView编辑列名称

有没有办法在DataGridView中编辑列名?