转换大写人民币

 

using  System;
using  System.Data;
using  System.Configuration;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
using  System.IO;
using  System.Text;
    
/**/ ///   <summary>
    
///  Convert 的摘要说明。
    
///   </summary>
public   class  ToDaXie
{
    
public  ToDaXie()
    {
        
//
        
//  TODO: 在此处添加构造函数逻辑
        
//
    }

    
private   static   string [] cstr  = " " " " " " " " " " " " " " " " " " " "  };
    
private   static   string [] wstr  = "" " " " " " " " " " " " " " " " " " " " " " " " "  };
    
private   static   string [] samll  = "" " " " "  };
    
/**/ ///   <summary>
    
///  转换大写人民币.
    
///   </summary>
    
///   <param name="str"></param>
    
///   <returns></returns>
     public   static   string  ConvertInt( string  str)
    {
        
string [] AllStr  =  str.Split( ' . ' );
        
int  len  =  AllStr[ 0 ].Length;
        
int  i;
        
string  tmpstr, rstr;
        rstr 
=   "" ;
        
// 从1开始.
         for  (i  =   1 ; i  <=  len; i ++ )
        {
            tmpstr 
=  AllStr[ 0 ].Substring(len  -  i,  1 );
            rstr 
+=   string .Concat(wstr[i] + cstr[Convert.ToInt32(tmpstr)]);
        }
        
// 倒排.
        StringBuilder sb  =   new  StringBuilder();
        
for  (i  =  rstr.Length  -   1 ; i  >=   0 ; i -- )
        {
            sb.Append(rstr[i]);
        }
        rstr 
=  sb.ToString();

        rstr 
=  rstr.Replace( " 拾零 " " " );
        rstr 
=  rstr.Replace( " 零拾 " "" );
        rstr 
=  rstr.Replace( " 零佰 " "" );
        rstr 
=  rstr.Replace( " 零仟 " "" );
        rstr 
=  rstr.Replace( " 零萬 " " " );

        
if  (AllStr[ 1 ==   "" )
        {
            
return   " "   +  rstr  +   " " ;
        }
        
else
        {
            
string  Arstr  =   "" ;
            
string  strr  =  AllStr[ 1 ].Substring( 0 2 );
            
string  tmpstra  =   ""
            
for  (i  =   1 ; i  <=   2 ; i ++ )
            {
                tmpstra 
=  strr.Substring( 2   -  i,  1 );                
                Arstr 
+=   string .Concat(samll[i]  +  cstr[Convert.ToInt32(tmpstra)]);
            }

            
// 倒排.
            StringBuilder sba  =   new  StringBuilder();
            
for  (i  =  Arstr.Length  -   1 ; i  >=   0 ; i -- )
            {
                sba.Append(Arstr[i]);
            }
            Arstr 
=  sba.ToString();

            
return   " "   +  rstr  +  Arstr;

        }
    }
}

你可能感兴趣的:(转换)