C#编写的小程序
2016-12-20 来自:刘洪彬 1 人回应
这个程序的错误提示是

错误 1 未能找到类型或命名空间名称“SaveEmail”(是否缺少 using 指令或程序集引用?) G:\C#实验\第七章\实例7-5\实例7-5\Form1.cs 24 13 实例7-5

能不能看一下应该怎么改?



using
System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace 实例7_5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnCheakEmail_Click(object sender, EventArgs e) { SaveEmail saveEmail = new SaveEmail(); try { if (saveEmail.CheckEmail(txtEmail.Text)) { lblShow.Text = "检查成功"; } } catch(EmailErrorException ex) { lblShow.Text = ex.Message; } } } public class EmailErrorException : ApplicationException { public EmailErrorException() { } public EmailErrorException(string message) : base(message) { } public EmailErrorException(string message, System.Exception innerException) : base(message, innerException) { } public override string Message { get { return "Email格式不正确:" + base.Message; } } public class SaveEmail { public bool CheackEmail(string email) { string[] strSign = email.Split('@'); if (strSign.Length != 2 || strSign[0].Length == 0 || strSign[1].Length == 0) { throw new EmailErrorException("@符号不正确!"); } else { int index = strSign[1].IndexOf('.'); if (index <= 0 || index >= strSign[1].Length - 1) { throw new EmailErrorException(".符号不正确"); } } return true; } } } }
2016-12-25 来自:VNCSG

把SaveEmail这个class提出来。

或者SaveEmail saveEmail = new SaveEmail();

改为EmailErrorException.SaveEmail saveEmail=new EmailErrorException.SaveEmail();

您的回应

你还未登陆,不能回应!登陆