C#常用知识

1.非System.Web.UI.Page  的类中使用 session

object IsLogined = System.Web.HttpContext.Current.Session["IsLogined"];
if (IsLogined != null)
{
}

2. ViewState 中存储小量数据

private int ChannelId
    {
        get
        {
            if (WebUtils.GetQueryInt("channelId", 0) > 0)
                ViewState["channelId"] = WebUtils.GetQueryInt("channelId", 0);
            return Utils.StrToInt(ViewState["channelId"],1);
        }
        set
        {
           ViewState["channelId"] =  value;
        }
    }

 

3. DataSet 里筛选数据

public DataSet GetPassedList()
{
    return this.GetDataSet(" [IsPassed] = 1   Order by  [GuestId]  Desc ");
}

DataSet 里筛选
 

public DataSet GetPassedList()
{
    return this.GetDataSet(" [IsPassed] = 1   Order by  [GuestId]  Desc ");
}

4. 人民币形式:

        decimal price;
        decimal discount;
        decimal discounted_price;

        // compute discounted price
        price = 19.95m;
        discount = 0.15m; // discount rate is 15%

        discounted_price = price - (price * discount);

        Console.WriteLine("Discounted price: {0:C}", discounted_price);

posted on 2009-03-30 14:21  alon  阅读(188)  评论(0编辑  收藏  举报

导航