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

  • Home
  • SEARCH
  • 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 6903365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:54:59+00:00 2026-05-27T07:54:59+00:00

I have a function that retrieves a list of device names and stores then

  • 0

I have a function that retrieves a list of device names and stores then in a variable. Then the next step is to get info using 1 device name per line and keep going till the loop is complete.

 String text = "";
        String errors = "";

    for (int i = 0; i < collection.Result.Count; i++)
    {
        deviceNames += collection.Result[i].DeviceName + Environment.NewLine;

        getvirtuals.Location = deviceNames;
        var virtuals = client.GetKnownVirtuals(getvirtuals, LtmKeyType.VirtualAddressPort);

        if (virtuals.Result == null)
        {
            i++;
            getvirtuals.Location = deviceNames;

        for (int v = 0; v < virtuals.Result.Count; v++)
                {
                try
                {
                    LtmKey virtualKey = new LtmKey();
                    virtualKey.Location = virtuals.Result[v].Location;
                    virtualKey.LocationType = virtuals.Result[v].LocationType;
                    virtualKey.Key = virtuals.Result[v].Key;
                    virtualKey.KeyType = LtmKeyType.VirtualAddressPort;

                    virtualKey.AdminGroup = admingroupComboBox.Text;


                    var memberStatus = client.GetMemberStatus(virtualKey);


                    for (int j = 0; j < memberStatus.Result.Count; j++)
                    {
                        VirtualMemberStatus status = memberStatus.Result[j];
                        text += String.Format("{5},{4},{0},{1},{2},{3}" + Environment.NewLine, status.Member.Address, status.Member.Port, status.EffectiveStatus, status.DesiredStatus, virtualKey.Key.Replace(":", ","), DateTime.UtcNow);
                        toolStripProgressBar1.PerformStep();
                    }
                }
                catch
                {
                    errors += String.Format("{0} Error Code: 2, Error occurred, check device name (case senstive) and admin group. This error may also occur due to connection loss, try again." + Environment.NewLine, DateTime.UtcNow);
                }
            }
            this.allResultsBox.Text = text;

        getallstatusButton.Enabled = true;
    }

    }

The problem that I am running into is that if virtuals is null the tool crashes, instead what I want to do is if virtuals = null I want to move onto the next item from the list. I have tried a if statement but it is not working the way planned, it still comes back as null.

  • 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-27T07:55:00+00:00Added an answer on May 27, 2026 at 7:55 am

    Well this seems like a problem to start with:

    if (virtuals.Result == null)
    {
        i++;
        getvirtuals.Location = deviceNames;
    
        for (int v = 0; v < virtuals.Result.Count; v++)
    
        ...
    

    If virtuals.Result is null, how do you expect virtuals.Result.Count to work? I suspect you meant:

    if (virtuals.Result != null)
    

    However, I suspect you really just want:

    // Keep going with the next iteration of the for loop
    if (virtuals == null || virtuals.Results == null)
    {
        continue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wave file, i have a function that retrieves 2 samples per
I have the following function that retrieves an image from a twitter feed, the
I have a function that returns two values in a list. Both values need
I have a function that takes an input string and then runs the string
I have a JS function that processes XML I GET from a server to
I have a function that allows me to expand and collapse an unordered list
I have a function in PHP that retrieves all the directories and files from
I have a function that returns the names and id's of my friends on
I have a class that retrieves data from core data and stores it into
I have the following code that should retrive the list of devices and get

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.