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;
......
1. 简述 private、 protected、 public、 internal 修饰符的访问权限。答 . private : 私有成员, 在类的内部才可以访问。 protected : 保护成员,该类内部和继承类中可以访问。 public : 公共成员,完全公开,没有访问限制。 internal: 在同一命名空间内可以访问。2 .列举ASP.NET 页面之间传递值的几种方式。 答. ......
http://ayic1.blog.163.com/blog/static/27343030200965103528805/
静态变量
当我们编写一个类时,其实就是在描述其对象的属性和行为,而并没有产生实质上的对象,只有通过new关键字才会产生出对象,这时系统才会分配内存空间给对象,其方法才可以供外部调用。
& ......
这是一个有关分页的实例,仅供参考(代码来自网络)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Threading;
using System.Collections;
us ......
public static void Main()
{
WebRequest req = WebRequest.Create("http://blog.csdn.net/xiaofengsheng");
try
& ......