从C#中的字符串中找到数字的索引 [英] Find index of number from a string in C#

查看:235
本文介绍了从C#中的字符串中找到数字的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

形成下面的字符串,我想获取起始编号的索引。请让我知道如何在C#.net中完成此操作。

Form the below string I would like to get the index of the starting number.Please let me know how this can be done in C#.net.

例如

University of California, 1980-85.  
University of Colorado, 1999-02 


推荐答案

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IndexOfAny
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("University of California, 1980-85".IndexOfAny("0123456789".ToCharArray()));
        }
    }
}

这篇关于从C#中的字符串中找到数字的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆