I have a code like this
int rpindex = allObjects.Find(new Guid(policyGuid));
if (rpindex != -1)
{
rp = (ResourcePolicy)allObjects.GetAt(rpindex);
}
and this is Find method
public virtual int Find(Guid guid)
{
try
{
for (int i=0; i<this.Count; i++)
{
if (guid.Equals(this[i].Guid))
{
return i;
}
}
}
catch(System.Exception exception)
{
SpoDebug.DebugTraceSevere(func, "Exception Occurred: " + exception.ToString() );
}
SpoDebug.DebugTraceVerbose(func, "no find. guid=" + guid.ToString());
return -1;
}
As of now the existing function Find() outcome is -1 or some integer value[i]. The -1 value will come in two situations , that is if the input is empty [ null value] and if the input is some value which is not in the database or in the current list, i need change here.That mean if the input to Find() is empty or null that time only it should return -1, otherwise if input has some value and it is not maching then it shud return return -2.SO there should be three outcomes one is -1 second is -2 and third is integer value ,Can any body guide me here
if i add else loop, i am not sure what return value i can use here other than -1, and integer value
just after the for loop check