oosumu

懒鬼,门外汉

博客园 首页 新随笔 联系 订阅 管理
    public bool isnumeric(string str)
        
{
            
char[] ch=new char[str.Length];
            ch
=str.ToCharArray();
            
for(int i=0;i<ch.Length;i++)
            
{
                
if(ch[i]<48 || ch[i]>57)
                    
return false;
            }

            
return true;
        }


        
public string coder(string source)
        
{
            
if(source!=string.Empty&&source!=null)
            
{
              

        source 
=source.Replace("<","<<");
        source
=source.Replace(">",">>");
        source
= source.Replace("\r\n""<br/>");
        source
= source.Replace("\n""<br/>");
        source  
= source.Replace(" ""&nbsp");
    
                
return source;
            }

            
else{
            
            
return source;
            }

        
        
        }
public bool IsNumeric(string s, out double result)
{
   
bool bReturn = true;
   
try
   
{
       result 
= double.Parse(s);
   }

   
catch
   
{
       result 
= 0;
       bReturn 
= false;
   }

   
return bReturn;      
}
public int IsNumeric(string str)
{
      
int i;
      
if(str != null && Regex.IsMatch(str,@"^\d+$"))
                i 
= int.Parse(str);
      
else
                i 
= -1;
       
return i;
}
posted on 2005-01-12 21:15  - -  阅读(770)  评论(0编辑  收藏  举报