小颖传奇1.76特色服

散人公益,自由交易,

   ::  ::  ::  ::  :: 管理

1. 输出参数

string x my(string x,out int y)

{

........

}

my("k"out y);

这样调用后就可以直截得到y的值(y值是在my涵数里计算得到的)

2.结构涵数(就是一个结构类型,里面的数据类型有涵数)

struct my

{

public string x,y;

public string Name()

{

return x+" "+y;

}

}

3. 涵数重载(同一涵数名,只是参数类型/涵数类型要不一样)

4.委托(用途:当要选择操作多个涵数<要相同参数>时非常方便)

delegate double my(double x, double y); 
    protected void Page_Load(object sender, EventArgs e)
    {
        my x = new my(my1);  //这时x就相当于是涵数my1;

        Response.Write(x(4, 5));

    }
    private double my1(double x, double y)
    {
        return x * y;
    }
    private double my2(double x, double y)
    {
        return x / y;
    }

5.还回一个数组的涵数 

  泛型

static List<DriveInfo> getdrives()
        {
            int k = 0;
            DriveInfo[] drs = DriveInfo.GetDrives();
            List<DriveInfo> ddrs=new List<DriveInfo>();
            foreach (DriveInfo dd in drs)
            {
                k++;
                if (dd.Name == @"A:\" || k == mailto:drs.Length%7C%7Cdd.Name==@%22C:\")
                { }
                else
                {
                    ddrs.Add(dd);
                }
            }
            return ddrs;
        }

  数组

static FileInfo[] getfile(string name)
        {
           
                DirectoryInfo dir = new DirectoryInfo(name);

                FileInfo[] files = dir.GetFiles();
                return files;
           
        }

posted on 2009-04-18 10:15  xymir  阅读(105)  评论(0)    收藏  举报