在类别无法直接使用的一些对象或方法
生活随笔
收集整理的這篇文章主要介紹了
在类别无法直接使用的一些对象或方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一些對象或是方法,如Session, Response,Server等等,無法在類別中直接打,是因為沒有在類別中引用它們的名稱空間。這個名稱空間(namespace):System.Web。另外它們正確的寫為HttpContext.Current.Session,HttpContext.Current.Response 和HttpContext.Current.Server。
參考:??
代碼 using?System;using?System.Web;
///?<summary>
///?Summary?description?for?CodeDemo
///?</summary>
public?class?CodeDemo
{
????public?CodeDemo()
????{
????????//
????????//?TODO:?Add?constructor?logic?here
????????//
????}
????//下面列舉了幾個對象與方法
????public?void?t()
????{
????????HttpContext.Current.Session["mykey"]?=?"Session?content";
????????HttpContext.Current.Response.Write("Write?content.");
????????HttpContext.Current.Server.MapPath(@"z:\...\");?
????}
}
?
總結
以上是生活随笔為你收集整理的在类别无法直接使用的一些对象或方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 中文API合集(4)(1
- 下一篇: 知识管理促进企业组织能力提升