Reputation: 967
I am using StyleCop on my C# files and it gives the warning :
SA1108 : CSharp.Readability : A comment may not be placed within the bracketed statement
for the following block of code :
// checking if the person is born or not.
if (AgeUtilities.IsPersonBorn(person.BirthDate) == false)
{
Console.WriteLine("Error....The user is not yet born.");
}
// checking if the person's age is possible or not.
else if (AgeUtilities.IsPersonLongAgePossible(age, EXPECTEDAGELIMIT) == false)
{
Console.WriteLine("This age is not possible in Today's world.");
}
What is the significance of this warning?
Upvotes: 6
Views: 2338
Reputation: 451
StyleCop tells you that you should replace/reorganise your comment above the else-statement inside the brackets, like
// checking if the person is born or not
// if not: check if the person's age is possible or not
if (AgeUtilities.IsPersonBorn(person.BirthDate) == false)
{
Console.WriteLine("Error....The user is not yet born.");
}
else if (AgeUtilities.IsPersonLongAgePossible(age, EXPECTEDAGELIMIT) == false)
{
Console.WriteLine("This age is not possible in Today's world.");
}
Upvotes: 6