1. Remove Control Flag (Remove Control Flag)
Motivation)
Replace the control mark with a break or return statement.
Example
Public void CheckSecurity (string [] people)
{
String found = string. Empty;
For (int I = 0; I <people. Length; I ++)
{
If (found. Equals (""))
{
If (people [I]. Equals ("Don "))
{
Found = "Don ";
}
If (people [I]. Equals ("John "))
{
Found = "John ";
}
}
}
SomeDataCode (found );
}
Change
Public void CheckSecurity (string [] people)
{
String found = string. Empty;
For (int I = 0; I <people. Length; I ++)
{
If (found. Equals (""))
{
If (people [I]. Equals ("Don "))
{
Found = "Don ";
Break;
}
If (people [I]. Equals ("John "))
{
Found = "John ";
Break;
}
}
}
SomeDataCode (found );
}
Example
Public string FindPeople (string [] people)
{
String found = string. Empty;
For (int I = 0; I <people. Length; I ++)
{
If (found. Equals (""))
{
If (people [I]. Equals ("Don "))
{
Found = "Don ";
}
If (people [I]. Equals ("John "))
{
Found = "John ";
}
}
}
Return found;
}
Change
Public string FindPeople (string [] people)
{
String found = string. Empty;
For (int I = 0; I <people. Length; I ++)
{
If (found. Equals (""))
{
If (people [I]. Equals ("Don "))
{
Return "Don ";
& Nb