IndexOf methods in C # arrays

Source: Internet
Author: User
var array=[' REG ', ' 2018 ', ' 2018 ';

Array.indexof (' REG ')//0

Array.indexof (' R ')//-1

Array.indexof (' 2018′)//1

Array.indexof (2018)//-1

  • Arr.indexof (' orange ') output 0 because ' orange ' is the No. 0 element of the array, matches to and returns the subscript.
  • Arr.indexof (' o ') output-1 because this method does not perform a indexOf match on a per-element basis.
  • Arr.indexof (' 2016′) Output 1 because this method matches from scratch until the next table of the first array element is returned, instead of returning all matching subscripts.
  • Arr.indexof (2016) output-1 Note: Implicit type conversions are not done here.

IndexOf methods in C # arrays

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.