C#取得域名以及目录地址的方法
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace SinvanCMS.Common
{
/// <summary>
/// 全局类,当前域名,物理路径
/// </summary>
public class Application
{
/// <summary>
/// 获得url路径, http://localhost/www_dalian/fangyuan.asp 的app部分如:http://localhost/www_dalian
/// </summary>
public static string AppUrl
{
get
{
return "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + AppSiteName;
}
}
/// <summary>
/// 获得 http://localhost/www_dalian/fangyuan.asp 的 部分如:www_dalian
/// </summary>
public static string AppSiteName
{
get
{
string SiteAddress = "";
SiteAddress = System.Web.HttpContext.Current.Request.ApplicationPath.ToString();
相关文档:
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  ......
protected void Button6_Click(object sender, EventArgs e)
{
this.Label11.Text = HtmlEncode(this.TextBox3.Text);
}
protected static string HtmlEn ......
在相同字符串的许多操作上,使用StringBuilder类会比使用String对象更有效率。
当你对一个string对象赋值时,这时会生成一个这个对象的副本,如果你赋值多次的话在系统中就会保存多个这个对象的副本,会对系统资源造成很大的浪费,但是StringBuilder不会出先上述情况
String数据类型代表的 ......
这是一个有关分页的实例,仅供参考(代码来自网络)
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 ......
一、定义
String.Format是将指定的 String类型的数据中的每个格式项替换为相应对象的值的文本等效项。
如:
(1)
string p1 = "Jackie";
string p2 = "Aillo";
Response.Write(String.Format("Hello {0}, I'm {1}", p1, p2));
(2)
Response.Write(String.Format("Hello {0}, I'm {1}", "Jackie", "Aillo"));
这 ......