C# example- In the below example blnStatus is initialized to false.
//should not allow empty string or null string
public bool SetName(string strName)
{
bool blnStatus = false;
if (strName != string.Empty && strName != null)
{
Name = strName;
blnStatus = true;
}
return blnStatus;
}
Rule: Initialize the return variable to failure status value.
Rule: Make sure return variable is set to success status value at the right place.
No comments:
Post a Comment