下面这段代码错在哪里?

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

如题,我明明照例子敲得,为什么会报错?  
   
  <%@   page   language="c#"   runat="server"%>  
  <script   language="c#"   runat="server">  
  public   class   user  
  {  
  static   private   int   count;  
  static   public   int   count  
  {  
  get  
  {  
  return   count;  
  }  
  }  
  public   user  
  {  
  count++;  
  }  
  static   user()  
  {  
  count=0;  
  }  
  }  
  void   page_load()  
  {  
  user   a   =   new   user();  
  user   b   =   new   user();  
  user   c   =   new   user();  
  response.write(user.count);  
  }  
  </script>  
   
  说明:   在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。    
   
  编译器错误信息:   cs1609:   修饰符不能放置在属性或事件访问器声明中  
   
  源错误:  
   
     
   
  行   3:     public   class   user  
  行   4:     {  
  行   5:     private   static   int   count;  
  行   6:     public   static   int   count  
  行   7:     {  
     
   
  源文件:   f:\asp+test\haha.aspx         行:   5

· 网友精彩回答:

发表者:net_lover

public   class   user  
 

发表者:hasome

public   class   user===>public   class   user.

发表者:holysky

public   class   user  
  {  
  private   static   int   count;  
  public   static   int   count  
  {  
  get  
  {  
  return   count;  
  }  
  }  
  public   user()  
  {  
  count++;  
  }  
  static   user()  
  {  
  count=0;  
  }  
  }  
   
  这样写可以通过,返回结果是3

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved