用结构做为返回参数.
戓者使用ref关键字.
public struct param
{
public int i;
public string s;
}
public param aaa()
{
param aa = new param();
aa.i =10;
aa.s ="sdfsdf";
return aa;
}
戓者使用ref关键字.
public struct param
{
public int i;
public string s;
}
public param aaa()
{
param aa = new param();
aa.i =10;
aa.s ="sdfsdf";
return aa;
}
解决方案 »
- c#加密xml问题,求解答
- 数据库问题,adapter.update无法更新数据源
- C#简单例子求高手解答,小弟我就是想不通
- 求一个正则表达式
- Winform 如何保存用户登录后的纪录
- .net 2.0Bate和 1.1的政则表达式有区别麽?
- 请问一下怎么怎么获取comboBox1选中项的值呢?(分不多,先到先得,在线等待,谢谢)
- 如何使用正则对字符串进行多次匹配
- 紧急求助:winform程序当掉了。
- 有长沙的同志吗?我这里要招两个人。最好是学数学的,要求对数学有强烈兴趣和一定的水平(高中水平免谈!-:)。
- 关于C#,.NET,各位除了上CSDN,还有一些别的什么比较好的论坛么?
- C#里面怎么读证书里的公钥和私钥?
private string aaa(string aaa,out string bbb,ref string ccc)
{}
{
s = s2 + 1;
s2 = 12;
return s+ s2;
}int i;
int j=2;
int n = GetValue(out i, ref j);
{
...
}用引用参数 ref和out, 这样, 你此函数可以得到4个返回值
void test( out int a, out char b, ... )
{
a = 1;
b = 'b';
...
}
public static string[,] GetGoal(string strName,int iYear)
{
// 定义
string[,] strReturn=new string[6,3];
for(int i=0;i<6;i++)
{
for(int j=0;j<3;j++)
{
strReturn[i,j]="";
}
}
try
{
// 查询语句
}
catch
{
// 出现错误
return null;
}
// 返回数组
return strReturn;
}
{
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 dir, name;
SplitPath("c:\\Windows\\System\\hello.txt", out dir, out name);
Console.WriteLine(dir);
Console.WriteLine(name);
}
}
此例产生下列输出:c:\Windows\System\
hello.txt