在根目录新建一页面,名为 index.aspx,则 index.aspx.cs 文件的内容为:namespace WebApplication1
{
    public partial class index : System.Web.UI.Page
    {
    }
}如果在里面用 this.GetType() 获得的 FullName 居然是 “ASP.index_aspx”,按照平常类的观念,这里获得的名字应该是
“WebApplication1.index” 才对。换句话说,用 this.GetType() 和 typeof(WebApplication1.index) 是同一个类型的!请问为什么会这样? 有没有什么办法可以在这两种 Type 之间进行互转呢?
我只有33分了,只能给这么多了。谢谢大家!

解决方案 »

  1.   

    FullName 居然是 “ASP.index_aspx”,按照平常类的观念,这里获得的名字应该是
    “WebApplication1.index”
    ===>
     class A:  B
        {    }    class B
        {
          public  string GetTypeString()
            {
                return this.GetType().ToString();
            }
        }
    //测试
      A obj = new A();
                Response.Write(obj.GetTypeString());
      

  2.   

    this.GetType() 是返回当前实例的类型,
    当前的实例就是ASP.index_aspx
    ASP.index_aspx是继承index 这个类的,
    虽然代码写在index 中,但这个当前实例却是它的子类的实例.
      

  3.   

    原来是这样,我用 this.GetType().BaseType 就可以获取 index 这个类的 Type 了。非常谢谢你!