C# params关键字
代码:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Test("Jack"));//不传值,显示Jack
Console.WriteLine(Test("Jack", "Hi"));//传一个值,显示Jack Hi
Console.WriteLine(Test("Jack", "Hi", "How are you?"));//传多个值,显示Jack Hi How are you?
Console.ReadKey();
}
static string Test(string name, params string[] args)
{
string msg = name;
for (int i = 0; i < args.Length; i++)
msg += " " + args[i];
return msg;
}
}
}
注意事项:
一个函数中只能一个参数带params关键字;
带params关键字的参数必须是最后一个参数;
带params关键字的参数类型必须是一维数组;
相关文档:
http://www.knowsky.com/5723.html
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
......
The C# classes that you design will be used by code that you write and possibly by code that
other people write. Your C# classes may be used by a VB.NET application or from within an
ASP.NET page. Moreover, your classes may very well be used alongside other classes
designed by other .NET develope ......
文 / 李博(光宇广贞)
方法多态与类型多态
了解 OOP 的同学对类型多态都很熟悉了。话说,类型多态之多态便体现在方法上,那方法多态又是嘛玩儿?类型多态之类型指的是对像的类型,其方法是受对像约束的。方法多态便是不受对像类型约束的多态。具体区别在:
方法多态无需继承 ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using  ......
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......