Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:20:36+00:00 2026-05-24T00:20:36+00:00

I have a code like this int rpindex = allObjects.Find(new Guid(policyGuid)); if (rpindex !=

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:20:37+00:00Added an answer on May 24, 2026 at 12:20 am

    just after the for loop check

    if(i == this.Count) //i reached the end of the loop but no matches found
    {
     return -2;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have written code like this @Id @Column(nullable=false) @GeneratedValue(strategy=GenerationType.AUTO) public int getUserID() {
I understand that a method can have code like this: def m(p1:Int => Int)
I have a code like this: [Serializable] public class A { public int X
Have code like this: case R.id.button: int id=randImage(); imgView1.setImageResource(id); public int randImage() { Random
I have code like this... class Time { public: Time(int, int, int); void set_hours(int);
I have code like this @Override public void onCreate(Bundle savedInstanceState) { addItemsOnSpinnerOrgaLevel(); btn_getReport.setOnClickListener(new OnClickListener()
Say I have some code like this: class Foo { public: Foo(int v) :
I have a code that looks like this: int main () { fstream file;
So i have some code like this: void foo (int, int); void bar (
In my project I have a lot of code like this: int[][] a =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.