c#基础

来源:互联网 发布:淘宝笔记本主板 编辑:程序博客网 时间:2024/06/06 19:49

//定义数组
string[] logs = new string[] { "Application", "Security", "System" };

 

//最具通用性和可变长数组ArrayList
ArrayList arr = new ArrayList();
arr.Add(1);
arr.Add(2);
arr.Add(3);

foreach (object i in arr)
{
    Response.Write(i.ToString());
}

 

//获取指定精度的除法结果.a为被除数,b为除数,c为精度
return Math.Round(a / b, c);

 

//根据记录总数和每页记录数获取页总数,常用于分页功能中
return (int)Math.Ceiling((double)recordTotal / pagesize);

 

//Web项目中获取当前程序所在的物理路径
Response.Write(HttpRuntime.AppDomainAppPath);

 

//Windows程序获取当前程序运行路径
string path = System.Windows.Forms.Application.StartupPath.ToString();

原创粉丝点击