C# 属性

C# 抽象

C# 字符串

C# 泛型

C# 杂项

C# 新特性

C# LastIndexOfAny() 最后任何索引字符串

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

签名

句法 (Syntax)

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

范围

ch:字符型数组。

返回

它返回整数值。


C# String LastIndexOfAny() 方法示例

例子 (Example)

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

例子 (Example)

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


  • 使用社交账号登录,本站支持
全部评论(0)