一个跟输出参数 以OUT 修饰符声明 的方法
一个跟输出参数 以OUT 修饰符声明 的方法
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Vechicle
{
static void SplitPath(string path, out string dir, out string name)
{
int i = path.Length;
while (i > 0)
{
char ch = path[i - 1];
if(ch=='\\'||ch=='/'||ch==':') break;
i--;
}
dir=path.Substring(0,i);
name=path.Substring(i);
}
static void Main(string[] args)
{
string dir, name;
SplitPath("c:\\learncs\\hello.txt", out dir, out name);
Console.WriteLine(dir);
Console.WriteLine(name);
}
}
}
这样的函数为什么会输出的结果是:c:\learncs\
hello.txt
不理解?
问题点数:10、回复次数:3Top
1 楼weisunding(鼎鼎)回复于 2005-08-11 11:12:43 得分 0
out关键字就是用来输出参数的,可以直接修改out修改的参数。
你可以参考refTop
2 楼weisunding(鼎鼎)回复于 2005-08-11 11:13:28 得分 0
out关键字就是用来输出参数的,可以直接修改out修改的参数。
你可以参考refTop
3 楼jamesfay(狒狒)回复于 2005-08-11 13:39:53 得分 0
\\=\Top




