相关疑难解决方法(0)

C#GUI命名约定的最佳实践?

GUI,无论是用WinForms还是XAML编写,似乎在我看到的项目之间具有最广泛的命名约定.对于一个TextBox人的名字的简单,我已经看到了各种命名约定:

TextBox tbName      // Hungarian notation
TextBox txtName     // Alternative Hungarian
TextBox NameTextBox // Not even camelCase
TextBox nameTextBox // Field after field with TextBox on the end
TextBox TextBoxName // Suggested in an answer...
TextBox textBoxName // Suggested in an answer...
TextBox uxName      // Suggested in an answer...
TextBox name        // Deceptive since you need name.Text to get the real value
TextBox textBox1    // Default name, as bad as you can get
Run Code Online (Sandbox Code Playgroud)

我通常会遵守所有.cs文件的StyleCop规则,并且看到其他人也这样做,但GUI往往会违反这些规则或变化很大.我没有看到任何专门引用GUI元素的Microsoft指南,而不仅仅是普通变量,甚至是在控制台应用程序之外应用的示例.

在GUI中命名元素的最佳实践是什么?

c# user-interface naming-conventions winforms

69
推荐指数
4
解决办法
4万
查看次数

无法将类型'string'隐式转换为'System.Windows.Forms.TextBox'

我不知道该怎么办,因为错误在于Form1.Designer.cs,因为我没有调试程序部分的经验.

//Form1
// 
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(352, 246);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Generate Username";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
Run Code Online (Sandbox Code Playgroud)

c#

7
推荐指数
2
解决办法
3万
查看次数

标签 统计

c# ×2

naming-conventions ×1

user-interface ×1

winforms ×1