Follow variable naming conventions
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
ID: csharp-code-style/variable-naming-conventions
Language: C#
Severity: Notice
Category: Code Style
Description
Variable names should follow the camelCase
pattern and start with a lowercase letter, except for private and protected fields that should start with _
.
Learn More
Non-Compliant Code Examples
class My_Class {
int MyVariable = 10;
public void foo() {
int FooBar = 14;
int BAZ_QUUX = 3;
DateTimeOffset t1 = TimeZoneInfo.ConvertTime();
}
}
Compliant Code Examples
public class CertificateHelperTests {
private const string PemCertPublic = "";
}
class My_Class {
int _myVariable = 10;
[TestMethod]
public void BooleanToIntegerConverterTest()
{
var converter = new BooleanToIntegerConverter
{
ValueOnTrue = 1,
ValueOnFalse = 2
};
Assert.AreEqual(1, converter.Convert(true, typeof(int), null, null));
Assert.AreEqual(2, converter.Convert(false, typeof(int), null, null));
}
}
class My_Class {
int myVariable = 10;
}