c#入门从字符串中分离数字

2008-04-10 15:35

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            split(str);
        }
        private static void split(string str)
        {
            string numstr ="";
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] <= '9' & str[i] >= '0')
                    numstr += str[i];

            }
            Console.WriteLine(numstr);
        }
    }
}

posted @ 2010-02-03 09:43  玄魂  阅读(2458)  评论(0编辑  收藏  举报