您的位置:程序门 -> .net技术 -> c#



c#高手帮帮我,叩谢先!----一个关于c#参数数组的问题????


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


c#高手帮帮我,叩谢先!----一个关于c#参数数组的问题????
发表于:2007-07-25 10:58:10 楼主
程序如下:
using   system;
using   system.collections.generic;
using   system.text;

namespace   consoleapplication27
{
        class   program
        {
                static   string   getword(params   string[]firstword)
                {   return   firstword[0];   }
                static   void   main(string[]   args)
                {
                        string   firstword   =   getword( "this   is   a   sentence. ");//字符串转化为数组了
                        console.writeline(firstword);
                       
                }
        }
}

问题:
怎么通过getwor函数得到字符串 "this   is   a   sentence. "中的单个单词,例如 "this "或者 "sent ",谢谢.
还有,在函数调用的开始,系统自动把字符串 "this   is   a   sentence. "转化为string[]firstword数组了吗?
发表于:2007-07-25 11:57:061楼 得分:0
简单,你可以用string类的
public   string[]   split   (params   char[]   separator)
方法实现,其中分隔符为空格就可以了!~看来你对库很不熟悉啊!   ^_^
发表于:2007-07-25 14:00:442楼 得分:0
问问题,竟然没有分,郁闷


快速检索

最新资讯
热门点击