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 6660003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:06:03+00:00 2026-05-26T02:06:03+00:00

I have a method GetSelectedServices() which returns Selected Nodes from a Tree List, Expecting

  • 0

I have a method GetSelectedServices() which returns Selected Nodes from a Tree List,
Expecting to return with the same method selected nodes and all Nodes i tried to add an out parameter.

But when I call this method i’m supposed to give the out parameter and so the returned list with selectedNodes is masked, and i cannot have it.

My Method

internal List<__ServiceInfo> GetSelectedServices(out List<__ServiceInfo> lstAll)
{
    List<__ServiceInfo> lstSelected = new List<__ServiceInfo>();
    List<__ServiceInfo> lstA = new List<__ServiceInfo>();

    foreach (TreeListNode node in this.tlServices.Nodes)
    {
        if (node.Checked)
        {
            var service = this.tlServices.GetDataRecordByNode(node) as __ServiceInfo;
            lstA.Add(service);

            if (service != null)
            {
                lstSelected.Add(service);
            }

            if (node.Nodes.Count > 0)
            {
                foreach (TreeListNode subNode in node.Nodes)
                {
                    if (subNode.Checked)
                    {
                        service = this.tlServices.GetDataRecordByNode(subNode) as __ServiceInfo;
                        lstA.Add(service);

                        if (service != null)
                        {
                            lstSelected.Add(service);
                        }
                    }
                }
            }
        }
    }
    lstAll = lstA;

    return lstSelected;
}

The way I call the method

public bool HasValidModel()
{
    List<__ServiceInfo> lstAll = new List<__ServiceInfo>();
    //here I get all nodes
    var allServices = this.GetAllServices(out lstAll);

    List<__ServiceInfo> lstSelected = new List<__ServiceInfo>();
    //but how to get the list from  ""return lstSelected"";
}

thank you for any suggestions.

  • 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-26T02:06:03+00:00Added an answer on May 26, 2026 at 2:06 am

    Just use two variables, like this:

    List<__ServiceInfo> lst;
    List<__ServiceInfo> lstSelected = GetSelectedServices(out lst);
    

    The ‘return’ed object is now referenced by lstSelected, while the outed object is referenced by lst.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have method List<Foo> getFoos () which gets the data from remote server and
I have class method that returns a list of employees that I can iterate
I have a method in .NET (C#) which returns string[][] . When using RegAsm
I have method in my N-layered application that returns List<Employee> . Below is the
Hii I have method in C#, I have to return multiple values from that
Folks, I have method that returns true if all characters are legal and false
I have method which return the latitude of the location public double[] getlat(){ double
I have a method which takes params object[] such as: void Foo(params object[] items)
I have a method in my Python code that returns a tuple - a
I have a method that can return either a single object or a collection

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.