C # Writing of ternary operators and traversing the list

Source: Internet
Author: User

C # statement of ternary operators: three operands A1, A2, and A3 expressions a1 = A2> A3? A2: A3 indicates that if A2> A3, a1 = a2, otherwise a1 = A3

 

Returns the first traversal element:

///


/// return the path of the current column, no more than Level 3
///
///
///
//
Public String getnodepath (ym_columns YC, list yclist)
{< br> If (YC. fatherid = 0)
return YC. ID + suffix;
else
{< br> ym_columns parent1 = yclist. find (o) => {return O. id = YC. fatherid;}); // The find method is to traverse the list yclist, Returns the first matched element
If (parent1.fatherid! = 0)
{< br> ym_columns parent2 = yclist. find (o) => {return O. id = parent1.fatherid;});
If (parent2.fatherid = 0)
{< br> return parent2.id + suffix + "/" + parent1.id + suffix + "/" + YC. ID + suffix;
}< br> else
{< br> return "path error ";
}< BR >}< br> else
return parent1.id + suffix + "/" + YC. ID + suffix;
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.