当前位置: 首页>>代码示例>>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;未经允许,请勿转载。