c#如何用结构或类来传递多个参数(例子源码)-c#编程习惯
c#中有条习惯用结构或类来传递多个参数,我这里举个例子如下:
using System;
namespace teststruct
{
public class People
{
public string Name;
public int age;
public string weburl;
}
class Program
{
static void Main(string[] args)
{
People p = new People();
p.Name = "云飞扬";
p.age = 27;
p.weburl = "http://www.ajaxcn.net";
Print o = new Print();
o.output(p);
Console.ReadKey();
}
}
public class Print
{
public void output(People p)
{
Console.WriteLine(p.Name +"的年龄是:"+ p.age.ToString());
Console.WriteLine("网址是:" + p.weburl);
}
}
}
原创文章转载请注明出处:云飞扬IT的blog
分类: c#