主题:新人问题用C#控制台程序求Email地址的合法性
			
 Fs_rong123
				 [专家分:0]  发布于 2010-08-20 00:34:00							
			判断一个字符串,是否是Email地址(第一个和最后一个字符不能是@和.号,只能有一个@和.号,并且不能有,号,且.号必须在@后面)。要用控制台程序输出的源代码![em18]
			最后更新于:2010-08-20 00:57:00
			
					 
		
			
回复列表 (共1个回复)
		
								
				沙发
				
					
wanghu_song [专家分:0]  发布于 2010-10-16 22:26:00				
				int email = txtUserEmail.Text.IndexOf("@");            
int spot = txtUserEmail.Text.LastIndexOf(".");
         if (email<0)            
            {
                MessageBox.Show("E-Mail格式不对,请重新输入!", "系统提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtUserEmail.Text = "";
                txtUserEmail.Focus();            
            }
         else if (spot < 0)            
            {
                MessageBox.Show("E-Mail格式不对,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUserEmail.Text = "";
                txtUserEmail.Focus();
            }
							 
									
			
我来回复