Several parameter conversion methods used by C # itself

Source: Internet
Author: User
Tags md5 encryption

 /// <summary>    ///Method:commandhelper///Author:liuyangyi///data:2016-05-10/// </summary>     Public classCommand {///provides a method for standard MD5 encryption/// </summary>        /// <param name= "Cort" ></param>        /// <returns></returns>        /// <summary>        ///standard MD5 cipher encryption algorithm/// </summary>        /// <param name= "tocrystring" ></param>        /// <returns></returns>         Public Static stringEXT_GETSTANDMD5 (stringtocrystring)            {MD5CryptoServiceProvider hashmd5; HASHMD5=NewMD5CryptoServiceProvider (); returnBitconverter.tostring (Hashmd5.computehash (Encoding.Default.GetBytes (Tocrystring.trim ())). Replace ("-","").        ToUpper (); }        /// <summary>        ///Unix time Stamp/// </summary>        /// <param name= "DateTime" ></param>        /// <returns></returns>         Public Static stringDatetimetounixtimestamp () {datetime datetime=DateTime.Now; varStart =NewDateTime (1970,1,1,0,0,0, Datetime.kind); returnConvert.toint64 (DateTime-start). totalseconds).        ToString (); }        /// <summary>        ///Time Format/// </summary>        /// <returns></returns>         Public Static stringDatetimestamp () {datetime datetime=DateTime.Now; returnDateTime.ToString ("YYYY-MM-DD HH:mm:ss"); }        /// <summary>        ///remove null and signature parameters from the array and sort them in alphabetical order from A to Z/// </summary>        /// <param name= "Dicarraypre" >parameter groups prior to filtering</param>        /// <returns>Filtered parameter Groups</returns>         Public Staticdictionary<string,Object> Filterpara (sorteddictionary<string,Object>dicarraypre) {Dictionary<string,Object> Dicarray =Newdictionary<string,Object>(); foreach(keyvaluepair<string,Object> Tempinchdicarraypre) {                if(temp. Key.tolower ()! =" Sign"&& temp. Value! =NULL&& temp. Value! ="") {Dicarray.add (temp. Key, temp.                Value); }            }            returnDicarray; }        /// <summary>        ///         ///parameters for sorting and purging to null/// </summary>        /// <param name= "O" ></param>        /// <returns></returns>         Public StaticDictionary<string, object>tomap (Object o) {sorteddictionary<string, object> map =Newsorteddictionary<string,Object>(); Type T=O.gettype (); propertyinfo[] Pi= T.getproperties (BindingFlags.Public |bindingflags.instance); foreach(PropertyInfo Pinchpi) {MethodInfo mi=P.getgetmethod (); if(Mi! =NULL&&mi. IsPublic) {map. Add (P.name, MI. Invoke (O,New( object[] {})); }            }            returnFilterpara (map); }        /// <summary>        ///concatenation of all elements of an array with "&" characters in the pattern "parameter = parameter value" into a string/// </summary>        /// <param name= "Dicarray" ></param>        /// <returns></returns>         Public Static stringCreatelinkstring (dictionary<string,Object>Dicarray) {StringBuilder Prestr=NewStringBuilder (); foreach(keyvaluepair<string,Object> TempinchDicarray) {                if(temp. Key.tolower ()! =" Sign"&& temp. Key.tolower ()! ="PID"&& temp. Value! =NULL&& temp. Value! ="") {prestr. Append (temp. Key+"="+ Temp. Value.tostring (). Replace (" ","") +"&"); }            }            //Remove the last & character            intNlen =Prestr.            Length; Prestr. Remove (Nlen-1,1); returnPrestr.        ToString (); }    }

Several parameter conversion methods used by C # itself

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.