當前位置: 首頁>>代碼示例>>C#>>正文


C# String.Trim方法代碼示例

本文整理匯總了C#中System.String.Trim方法的典型用法代碼示例。如果您正苦於以下問題:C# String.Trim方法的具體用法?C# String.Trim怎麽用?C# String.Trim使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.String的用法示例。


在下文中一共展示了String.Trim方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: cmd

        public String cmd(String cnd)
        {

            cnd = cnd.Trim();
            String output = " ";
            Console.WriteLine(cnd);

            if ((cnd.Substring(0, 3).ToLower() == "cd_") && (cnd.Length > 2))
            {

                if (System.IO.Directory.Exists(cnd.Substring(2).Trim()))
                    cpath = cnd.Substring(2).Trim();

            }
            else
            {
                cnd = cnd.Insert(0, "/B /c ");
                Process p = new Process();
                p.StartInfo.WorkingDirectory = cpath;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.Arguments = cnd;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.Start();
                output = p.StandardOutput.ReadToEnd();  // output of cmd
                output = (output.Length == 0) ? " " : output;
                p.WaitForExit();

            }
            return output;
        } // end cmd 
開發者ID:TheBugMaker,項目名稱:Payload-Client,代碼行數:32,代碼來源:Tools.cs

示例2: RepositoryFile

		public RepositoryFile(IRepository repository, String path, RepositoryStatus contentsStatus, RepositoryStatus propertiesStatus)
		{
			if (path == null)
				throw new ArgumentNullException("path");
			if (path.Trim().Length == 0)
				throw new ArgumentException("Path must be set to a valid path", "path");
			if (path[path.Length-1] == '/')
				throw new ArgumentException("Path must be set to a file, not a directory", "path");
			if (propertiesStatus == RepositoryStatus.Added ||
				propertiesStatus == RepositoryStatus.Deleted)
			{
				throw new ArgumentException("Properties status cannot be set to Added or Deleted, use Updated", "propertiesStatus");
			}
			
			this.contentsStatus = contentsStatus;
			this.propertiesStatus = propertiesStatus;
			this.repository = repository;
			SetPathRelatedFields(path);

			if (fileName.EndsWith(" "))
				throw new ArgumentException("Filename cannot end with trailing spaces", "path");

			if (fileName.StartsWith(" "))
				throw new ArgumentException("Filename cannot begin with leading spaces", "path");

		}
開發者ID:atczyc,項目名稱:castle,代碼行數:26,代碼來源:RepositoryFile.cs

示例3: Logger

        public Logger(String outputLocation)
        {
            if (writer != null)
            {
                writer.Flush();
                writer.Close();
            }

            FileStream ostrm;
            TextWriter oldOut = Console.Out;
            if (outputLocation != null)
            {
                try
                {
                    ostrm = new FileStream(outputLocation.Trim(), FileMode.OpenOrCreate, FileAccess.Write);
                    ostrm.SetLength(0); // clear the file
                    ostrm.Flush();
                    writer = new StreamWriter(ostrm);
                    writer.AutoFlush = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Cannot open " + outputLocation.Trim() + " for writing");
                    Console.WriteLine(e.Message);
                    return;
                }
            }
        }
開發者ID:ChristianKapfhammer,項目名稱:SPLConqueror,代碼行數:28,代碼來源:Logger.cs

示例4: SapTable

 /// <summary>
 /// 初始化,需要sap係統名與表名,表名與結構名一致。
 /// </summary>
 /// <param name="psysName"></param>
 /// <param name="pTableName"></param>
 public SapTable(String psysName, String pTableName)
 {
     SystemName = psysName;
     TableName = pTableName.Trim().ToUpper();
     StructureName = pTableName.Trim().ToUpper();
     // prepareFieldsFromSapSystem();
 }
開發者ID:SyedMdKamruzzaman,項目名稱:sap_interface,代碼行數:12,代碼來源:SapTable.cs

示例5: calculateTheAliveValue

        /// <summary>計算value值</summary>
        public void calculateTheAliveValue(IToken token, String condition)
        {
            if (!token.IsAlive)
            {
                return;//如果token是dead狀態,表明synchronizer的joinpoint是dead狀態,不需要重新計算。
            }
            //1、如果沒有轉移條件,默認為true
            if (condition == null || condition.Trim().Equals(""))
            {
                token.IsAlive=true;
                return;
            }
            //2、default類型的不需要計算其alive值,該值由synchronizer決定
            if (condition.Trim().Equals(ConditionConstant.DEFAULT))
            {
                return;
            }

            //3、計算EL表達式
            try
            {
                Boolean alive = determineTheAliveOfToken(token.ProcessInstance.ProcessInstanceVariables, condition);
                token.IsAlive=alive;
            }
            catch (Exception ex)
            {
                throw new EngineException(token.ProcessInstanceId, token.ProcessInstance.WorkflowProcess, token.NodeId, ex.Message);
            }
        }
開發者ID:magoo-lau,項目名稱:fireflow,代碼行數:30,代碼來源:TransitionInstanceExtension.cs

示例6: DocDbFormatIPC

 //返回IPC中/前的所有字符串加/後的4個字符
 public static String DocDbFormatIPC(String ipc)
 {
     if (ipc.Trim() == "")
     {
         return ipc.Trim();
     }
     else if (!ipc.Contains('/'))
     {
         return ipc.Split(' ')[0].Trim();
     }
     else
     {
         String[] tem = ipc.Split('/');
         String result = ipc.Split('/')[0].Trim() + "/";
         if (tem[1].Length > 4)//隻取/後的4個字符
         {
             result = result + tem[1].Substring(0, 4).Trim();
         }
         else
         {
             result = result + tem[1].Trim();
         }
         return result;
     }
 }
開發者ID:xy19xiaoyu,項目名稱:TG,代碼行數:26,代碼來源:FormatUtil.cs

示例7: addException

 public void addException(String exception)
 {
     if (!WhiteList.Contains(exception.Trim().ToLower()))
     {
         WhiteList.Add(exception.Trim().ToLower());
     }
 }
開發者ID:alexcassol,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:7,代碼來源:DataRegister.cs

示例8: sendpayment

    public string sendpayment(String apiusername, String apipassword, String amount, String sender, String reason)
    {
        DataTable dt = new DataTable();
        string result = null;
        string holdserial = null;

        SqlConnection mycoon=myreadconn.realreadconn();

        my_storedpro.username = reason.Trim();
        my_storedpro.amount = double.Parse(amount);
        my_storedpro.controller = sender.Trim();
        my_storedpro.balbefore = double.Parse(get_bal(reason.Trim()).ToString());

        holdserial = myreadconn.GetNextMobileSerial(mycoon);

        my_storedpro.serial = (holdserial.Trim() + sender.Trim()).Trim();

        myreadconn.EditNextMobileSerial(holdserial, mycoon);

        if ((apiusername == "globalbets") && (apipassword == "dewilos"))
        {
            result = my_storedpro.epay();

        }
        return result + "|" + my_storedpro.serial;
    }
開發者ID:KazibweStephen,項目名稱:beta,代碼行數:26,代碼來源:epay.cs

示例9: Create

        public ActionResult Create([Bind(Include = "BookID,Title,Genre")] Book book,String AuthorName)
        {
            if (ModelState.IsValid)
            {
                var auToCheck = from auth in db.Authors
                                where auth.AuthorName == AuthorName
                                select auth;
                if (AuthorName.Trim() != auToCheck.FirstOrDefault().AuthorName.Trim())
                {
                    Author au = new Author();
                    au.AuthorName = AuthorName.Trim();
                    db.Authors.Add(au);
                    au.Books.Add(book);
                    book.Authors.Add(au);

                }
                else
                {
                    book.Authors.Add(auToCheck.FirstOrDefault());
                }
                db.Books.Add(book);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(book);
        }
開發者ID:sug27,項目名稱:BootCampWork,代碼行數:27,代碼來源:BooksController.cs

示例10: Guid

        public void 添加錯誤消息(String 異常描述, String 異常代碼, String 異常信息, int 異常級別, int 異常類型, String 主機名稱, String 方法名稱, String 消息編碼, String 綁定地址編碼, int 異常信息狀態, String 請求消息體, int 請求類型, String 請求密碼, int 綁定類型)
        {
            //bool isAddOk = true;
            錯誤消息處理邏輯 錯誤邏輯 = new 錯誤消息處理邏輯();
            異常信息對象 異常對象 = new 異常信息對象();
            異常對象.異常時間 = System.DateTime.Now;
            異常對象.異常描述 = 異常描述.Trim();
            異常對象.異常代碼 = 異常代碼.Trim();
            異常對象.異常信息 = 異常信息.Trim();
            異常對象.異常級別 = 異常級別;
            異常對象.異常類型 = 異常類型;
            異常對象.主機名稱 = 主機名稱.Trim();
            異常對象.方法名稱 = 方法名稱.Trim();
            異常對象.請求密碼 = 請求密碼.Trim();
            異常對象.綁定類型 = 綁定類型;
            異常對象.請求類型 = 請求類型;
            異常對象.消息編碼 = new Guid(消息編碼);
            異常對象.綁定地址編碼 = new Guid(綁定地址編碼);
            異常對象.異常信息狀態 = 異常信息狀態;
            異常對象.請求消息體 = 請求消息體;
            XmlDocument document = new XmlDocument();
            document.LoadXml(請求消息體);

            string serviceName = document.DocumentElement.SelectSingleNode("服務名稱").InnerText.Trim();
            string reqBeginTime = document.DocumentElement.SelectSingleNode("請求時間").InnerText.Trim();

            //Audit.AuditServcie auditServcie = new JN.ESB.Exception.Service.Audit.AuditServcie();
            //auditServcie.AddAuditBusiness(主機名稱, 請求消息體, 消息編碼, 方法名稱, reqBeginTime, serviceName, 0);
            服務目錄業務邏輯 UDDI = new 服務目錄業務邏輯();
            List<個人> 係統管理員 = UDDI.獲得係統管理員();
            if ((String.IsNullOrEmpty(綁定地址編碼.Trim()) || 綁定地址編碼.Trim() == "00000000-0000-0000-0000-000000000000"))
            {
                
                if(UDDI.獲得綁定信息_服務名稱(serviceName)!=null){
                    異常對象.綁定地址編碼 = UDDI.獲得綁定信息_服務名稱(serviceName).服務地址編碼;
                }
            }

            錯誤邏輯.創建錯誤消息(異常對象);

            try
            {
                if (!(異常對象.綁定地址編碼.Value == Guid.Empty))
                {
                    服務地址 地址 = UDDI.獲得綁定信息_服務地址編碼(異常對象.綁定地址編碼.Value);
                    個人 服務管理員 = UDDI.獲得管理員_具體綁定服務(地址);
                    if (!(係統管理員.Contains(服務管理員)))
                        係統管理員.Add(服務管理員);
                    

                }
                this.發送OA郵件(異常對象, 係統管理員);
            }
            catch { }
            
            
        }
開發者ID:vebin,項目名稱:soa,代碼行數:57,代碼來源:錯誤消息服務.asmx.cs

示例11: removeException

 public bool removeException(String exception)
 {
     bool pass = false;
     if (WhiteList.Contains(exception.Trim().ToLower()))
     {
         WhiteList.Remove(exception.Trim().ToLower());
     }
     return pass;
 }
開發者ID:alexcassol,項目名稱:Terraria-s-Dedicated-Server-Mod,代碼行數:9,代碼來源:DataRegister.cs

示例12: HandleMessage

 public static void HandleMessage(String message, ref bool displayMessage)
 {
     if (!MyAPIGateway.Multiplayer.IsServer || !message.Trim().ToLower().StartsWith("dc"))
     {
         displayMessage = true;
         return;
     }
     gMessage = message.Trim().Substring(2).Trim();
     displayMessage = false;
 }
開發者ID:sanzone13,項目名稱:DroneConquest,代碼行數:10,代碼來源:ChatMessageHandler.cs

示例13: extractMimePart

 /**
 * Extract the mime part from an Http Content-Type header
 */
 public static String extractMimePart(String contentType) 
 {
     contentType = contentType.Trim();
     int separator = contentType.IndexOf(';');
     if (separator != -1) 
     {
         contentType = contentType.Substring(0, separator);
     }
     return contentType.Trim().ToLower();
 }
開發者ID:s7loves,項目名稱:pesta,代碼行數:13,代碼來源:ContentTypes.cs

示例14: RDFVariable

 /// <summary>
 /// Default-ctor to build a named SPARQL variable
 /// </summary>
 public RDFVariable(String variableName)
 {
     if (variableName != null && variableName.Trim() != String.Empty) {
         this.VariableName     = "?" + variableName.Trim().ToUpperInvariant();
         this.PatternMemberID  = RDFModelUtilities.CreateHash(this.ToString());
     }
     else {
         throw new RDFQueryException("Cannot create RDFVariable because given \"variableName\" parameter is null or empty.");
     }
 }
開發者ID:mdesalvo,項目名稱:RDFSharp,代碼行數:13,代碼來源:RDFVariable.cs

示例15: IsFullUrl

 // ------------------------------ Url ---------------------------------------
 /// <summary>
 /// 檢查url是否完整(是否以http開頭或者以域名開頭)
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static Boolean IsFullUrl( String url ) {
     if (strUtil.IsNullOrEmpty( url )) return false;
     if (url.Trim().StartsWith( "/" )) return false;
     if (url.Trim().StartsWith( "http://" )) return true;
     String[] arrItem = url.Split( '/' );
     if (arrItem.Length < 1) return false;
     int dotIndex = arrItem[0].IndexOf( "." );
     if (dotIndex <= 0) return false;
     return hasCommonExt( arrItem[0] ) == false;
 }
開發者ID:mfz888,項目名稱:xcore,代碼行數:16,代碼來源:PathHelper.cs


注:本文中的System.String.Trim方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。