用out或ref
bool myFunc(string sDataSource, string sDatabase, string sUsername, string sPassword, out string sRefreshTime);bool myFunc(string sDataSource, string sDatabase, string sUsername, string sPassword, ref string sRefreshTime);
bool myFunc(string sDataSource, string sDatabase, string sUsername, string sPassword, out string sRefreshTime);bool myFunc(string sDataSource, string sDatabase, string sUsername, string sPassword, ref string sRefreshTime);
An overload will occur if declarations of two methods differ only in their use of out. However, it is not possible to define an overload that only differs by ref and out
你看看这个程序就知道了。
using System;
using System.Collections;
class myTrim
{
public static void Main()
{
ArrayList al = new ArrayList();
test(al);
Console.WriteLine((int)al[0]);
Console.Read();
return;
} public static void test(ArrayList al)
{
al.Add(1);
}
}