C#教程
C#控制语句
C#函数
C#数组
C#面向对象
C#命名空间和异常
C#文件IO
C#集合
C#多线程
C#其它

C# String LastIndexOfAny()

C# String LastIndexOfAny()

C#LastIndexOfAny() 方法用于查找此字符串中指定的一个或多个字符最后一次出现的索引位置。

签名

public int LastIndexOfAny(Char[] ch)
public int LastIndexOfAny(Char[], Int32)
public int LastIndexOfAny(Char[], Int32, Int32)

参数

ch:是字符类型数组。

返回

它返回整数值。

C# String LastIndexOfAny() 方法示例

    using System; 
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
           string s1 = "abracadabra";
           char[] ch = {'r','b'};
           int index = s1.LastIndexOfAny(ch);//Finds 'r' at the last
           Console.WriteLine(index);
        }  
    }  
输出:
9

C# String LastIndexOfAny() 方法示例 2

    using System; 
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
           string s1 = "abracadabra";
           char[] ch = {'t','b'};
           int index = s1.LastIndexOfAny(ch);//Finds 'b' at the last
           Console.WriteLine(index);
        }  
    }  
输出:
8
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4