错误信息:预计类型或命名空间定义或文件结束, [英] Error Message: Type or namespace definition, or end-of-file expected

查看:2914
本文介绍了错误信息:预计类型或命名空间定义或文件结束,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索,所有以前的答案说,分号丢失。这不是问题。还有什么可以导致此错误?在第三个网站,有几个人问过这个问题,但这种情况是不同的。



错误是> <类型或命名空间定义或档案结尾STRONG>人口会 D



 公共部分类SeenSMS:System.Web.UI.UserControl 
{
//临时SQL连接
//公众的SqlConnection mycon;
的SqlConnection mycon =新的SqlConnection(@数据源= ASOFT20\MAMUT;初始目录= ViltraNew;用户名= SA;密码= sa123);


保护无效的Page_Load(对象发件人,EventArgs五)
{
的String [] = msg_arr的Request.QueryString [ARR]分割(| );

如果
{
串麋=的Request.QueryString [1](的IsPostBack!);
}

如果(msg_arr!= NULL)
{
如果((msg_arr.Length == 3)及及(msg_arr [1] .ToLower ()==slett))

{
INT小时= Convert.ToInt32(msg_arr [2]);

如果(时间大于0)
{
串的用户名= msg_arr [0];

的SqlCommand COM =新的SqlCommand(SELECT COUNT(*)作为计数从动物那里小时= @时mycon);
com.Parameters.AddWithValue(@时间,小时);使用
(SqlDataReader的读卡器= com.ExecuteReader())
{
如果(reader.HasRows)
{
,而(reader.Read())
{
// INT数= Convert.ToInt32(con.ExecuteReader());
INT数= Convert.ToInt32(读卡器[伯爵]);

}
}
,否则{

}
}
}
//如果(数字== 0)
// {
//的Response.Write(不当平原摘要);
//}
//别的
{

}


}
}


}

公共BOOL号{搞定;组; }
公共对象小时{搞定;组; }}



//公共System.Collections.Specialized.NameValueCollection穆斯{搞定;组; }



//公共字符串值{获得;组; }

//公共对象msg_arr {搞定;组; }
}
}


解决方案

该行:

 公共对象小时{搞定;组; }} 

您有redundand } 在结束


I've searched the internet, all previous answers said that a semicolon is missing. That's not the problem. What else can cause this error? In the third site, several people asked this question but this scenario is different.

Error is > Type or namespace definition, or end-of-file expected

 public partial class SeenSMS : System.Web.UI.UserControl
    {
    //temp sql connection
    //public SqlConnection mycon;
    SqlConnection mycon = new SqlConnection(@"Data Source=ASOFT20\MAMUT;Initial   Catalog=ViltraNew;UserID=sa;Password=sa123");


    protected void Page_Load(object sender, EventArgs e)
    {
        string[] msg_arr = Request.QueryString["arr"].Split('|');

        if (!IsPostBack)
        {
            string Moose = Request.QueryString[1];
        }

        if (msg_arr != null)
        {
            if ((msg_arr.Length == 3) && (msg_arr[1].ToLower() == "slett"))

            {
                int Hours = Convert.ToInt32(msg_arr[2]);

                if (Hours > 0)
                {   
                    string username = msg_arr[0];

                    SqlCommand com = new SqlCommand("SELECT count(*) as count  FROM Animal Where Hours=@Hours", mycon);
                    com.Parameters.AddWithValue("@Hours",Hours);
                    using (SqlDataReader reader = com.ExecuteReader())
                    {
                        if(reader.HasRows)
                        {
                        while (reader.Read())
                        {
                             // int number = Convert.ToInt32(con.ExecuteReader());
                            int number = Convert.ToInt32(reader["count"]);

                        }
                        }
                        else{

                        }
                    }
                }
             //   if( number == 0)
               // {
                   // Response.Write("Improper Plain Summaries.");
              //  }
             //   else
                {

                }


                }
            }


        }

  public  bool number { get; set; }
  public  object Hours { get; set; }}



   // public System.Collections.Specialized.NameValueCollection Moose { get; set; }



  //  public string Value { get; set; }

  //  public object msg_arr { get; set; }
}
 }

解决方案

This line:

public  object Hours { get; set; }}

Your have a redundand } at the end

这篇关于错误信息:预计类型或命名空间定义或文件结束,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆