当前位置: 首页>>代码示例>>C#>>正文


C# String.TrimEnd方法代码示例

本文整理汇总了C#中System.String.TrimEnd方法的典型用法代码示例。如果您正苦于以下问题:C# String.TrimEnd方法的具体用法?C# String.TrimEnd怎么用?C# String.TrimEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.TrimEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertStringToMilliseconds

        /// <summary>
        ///
        /// </summary>
        /// <param name="myString">String </param>
        /// <returns>The value in milliseconds</returns>
        public static Int32 ConvertStringToMilliseconds(String myString)
        {
            // Guard Block
            // String null
            // String ""
            // String "        "
            if (String.IsNullOrWhiteSpace(myString))
            {
                throw new ArgumentException("Value was null, empty, or not a recognized time format.");
            }

            // Try Parse in the hopes that they gave us a number without ANY suffix
            int num;
            bool res = int.TryParse(myString, out num);

            if (res)
            {
                // Log statement saying that we're good
            }
                // Hours suffix scenario - h
            else if (myString.EndsWith("h"))
            {
                myString = myString.TrimEnd(new char[] {'h'});
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 3600000;
                }
                
            }
                // Minute suffix scenario - m
            else if (myString.EndsWith("m"))
            {
                myString = myString.TrimEnd(new char[] { 'm' });
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 60000;
                }
            }
              // Second suffix scenario - s
            else if (myString.EndsWith("s"))
            {
                myString = myString.TrimEnd(new char[] { 's' });
                bool x = int.TryParse(myString, out num);
                if (x)
                {
                    num = num * 1000;
                }
            }
            else
            {
                throw new ArgumentException("Value is not a recognized time format.");
            }
            return num;
        }
开发者ID:catenn,项目名称:StringUtilityConversion,代码行数:61,代码来源:StringUtility.cs

示例2: I4ch

        /// <summary>
        /// Converts 4-byte integer array into character string.
        /// </summary>
        /// <param name="ibuf">Integer array to convert</param>
        /// <param name="nbyte">The number of bytes to convert (expected to be
        /// a multiple of 4)</param>
        /// <returns></returns>
        internal static string I4ch(int* ibuf, int nbyte)
        {
            Debug.Assert((nbyte%4) == 0);

            char[] res = new char[nbyte];
            for (int i=0, j=0; i<nbyte/4; i++, j+=4)
            {
                int val = ibuf[i];
            #if (_SUN)
                res[j+3] = (char)(val & 0x000000FF);
                res[j+2] = (char)((val & 0x0000FF00) >> 8);
                res[j+1] = (char)((val & 0x00FF0000) >> 16);
                res[j]   = (char)((val & 0xFF000000) >> 24);
            #else
                res[j]   = (char)(val & 0x000000FF);
                res[j+1] = (char)((val & 0x0000FF00) >> 8);
                res[j+2] = (char)((val & 0x00FF0000) >> 16);
                res[j+3] = (char)((val & 0xFF000000) >> 24);
            #endif
            }

            // Force any embedded nulls into blanks.

            for (int i=0; i<nbyte; i++)
            {
                if (res[i]=='\0')
                    res[i] = ' ';
            }

            // Strip off trailing white space
            string s = new String(res);
            return s.TrimEnd(null);
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:40,代码来源:Util.cs

示例3: findAppDocOfModule

 private XmlElement findAppDocOfModule(String pDir, String pIOCode) {
   XmlElement vRslt = null;
   String vAppCfgFN = pDir + "app.config";
   if(File.Exists(vAppCfgFN)) {
     XmlDocument vDoc = dom4cs.OpenDocument(vAppCfgFN).XmlDoc;
     XmlNodeList vMods = vDoc.DocumentElement.SelectNodes("load/module[not(@enabled) or (@enabled='true')]");
     foreach(XmlElement vMod in vMods) {
       //if((!vMod.HasAttribute("enabled") || String.Equals(vMod.GetAttribute("enabled"), "true", StringComparison.CurrentCultureIgnoreCase)) 
       //    && String.Equals(vMod.GetAttribute("iocode"), pIOCode, StringComparison.CurrentCultureIgnoreCase)) {
       if(String.Equals(vMod.GetAttribute("iocode"), pIOCode, StringComparison.CurrentCultureIgnoreCase)) {
         vRslt = vMod;
         break;
       }
     }
   }
   if((vRslt == null) && !String.IsNullOrEmpty(pDir)) {
     DirectoryInfo vCurDir = new DirectoryInfo(pDir);
     DirectoryInfo vPrntDir = Directory.GetParent(pDir.TrimEnd(new Char[]{'\\'}));
     if ((vPrntDir != null) && (vPrntDir.FullName.ToLower().StartsWith(this.BioSession.Cfg.LocalPath.ToLower()))) {
       String vNextIOCode = vCurDir.Name + "." + pIOCode;
       vRslt = this.findAppDocOfModule(vPrntDir.FullName + "\\", vNextIOCode);
     }
   }
   return vRslt;
 }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:25,代码来源:ABioHandlerBio.cs

示例4: InternalTrimTrailingSeparator

        /// <summary>
        /// Removes spaces end <see cref="DirectorySeparatorChar "/> at the end of a string
        /// </summary>
        internal static String InternalTrimTrailingSeparator( String path )
        {
            Contract.Requires( !String.IsNullOrWhiteSpace( path ) );
            Contract.Ensures( !String.IsNullOrWhiteSpace( Contract.Result<String>() ) );

            return path.TrimEnd( WhiteSpace ).TrimEnd( DirectorySeparatorChar );
        }
开发者ID:Invisibility,项目名称:QuickIO,代码行数:10,代码来源:QuickIOPath.cs

示例5: JsonToDictionary

        public Dictionary<string, string> JsonToDictionary(String input, String firstCol)
        {
            //if(input.IndexOf("{"
            //input = input.Replace('\"','');
            /*
            input = input.Substring(input.IndexOf("{" + firstCol) + 1);
            input = input.Substring(0, input.IndexOf("}"));
            */
            /*
            while (input.IndexOf('\\') >= 0)
            {
                int index = input.IndexOf('\\');
                input = input.Substring(0, index) + input.Substring(index + 1);
            }
            */

            input = input.Substring(1);
            input = input.Substring(0,input.Length-1);

            while (input.IndexOf('\"') >= 0)
            {
                int index = input.IndexOf('\"');
                input = input.Substring(0, index) + input.Substring(index + 1);
            }
            /*
            input.Replace(':', '=');
            input.Replace(',', ';');
            */
            return input.TrimEnd(',').Split(',').ToDictionary(item => item.Split(':')[0], item => item.Split(':')[1]);
        }
开发者ID:zajer,项目名称:ProKurier,代码行数:30,代码来源:JsonConverter.cs

示例6: ServerConnectionModel

        public ServerConnectionModel(String hostIP, String userName, String userPassword)
        {
            Host = hostIP;
            User = userName;
            Password = userPassword;

                Host.TrimEnd('/');
        }
开发者ID:hulvei3,项目名称:MusicStreamer,代码行数:8,代码来源:ServerConnectionModel.cs

示例7: SectionEntry

				public uint Offset; //the offset of this section in the nxz

				public SectionEntry(Stream stream)
				{
					BinaryReader rdr = new BinaryReader(stream);
					Name = new String(rdr.ReadChars(rdr.ReadByte()));
					Name = Name.TrimEnd('\0');//dont include the required terminator
					type = (Types)rdr.ReadByte();
					Length = rdr.ReadUInt32();
					u3 = rdr.ReadInt32();
				}
开发者ID:2asoft,项目名称:NoxMapEditor,代码行数:11,代码来源:VideoBag.cs

示例8: RegisterNamespaceMapping

 /// <summary>
 /// Map C# (server) class namespace to JS (client) namespace. Use * and % to define prefix mappings.
 /// </summary>
 /// <param name="ns">Name of the C# (server) namespace. If the name ends with *, prefix match is used. If the name ends with % only that part of namespace is mapped. </param>
 /// <param name="cns">Name of the JS (client) namespace.</param>
 public void RegisterNamespaceMapping(String ns, String cns)
 {
     namespaceMapping.Add(new NamespaceMapping
     {
         Namespace = ns.TrimEnd('*'),
         ClientNamespace = (cns ?? "").TrimEnd('*'),
         Mode = GetNamespaceMappingMode(ns, cns)
     });
 }
开发者ID:borisdj,项目名称:dextop,代码行数:14,代码来源:DextopModule.Namespaces.cs

示例9: StringToByteArray

 //hex轉byte用的
 public static byte[] StringToByteArray(String hex)
 {
     hex = hex.TrimEnd('\r', '\n');//trim CRLF
     int NumberChars = hex.Length;
     byte[] bytes = new byte[NumberChars / 2];
     for (int i = 0; i < NumberChars; i += 2)
         bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
     return bytes;
 }
开发者ID:knarf7112,项目名称:SocketServer,代码行数:10,代码来源:UnitTest_AsyncMultiSocket.cs

示例10: CopyToContainerAsync

        public async Task CopyToContainerAsync(
            IAsyncCommandContext context,
            String source,
            CancellationToken cancellationToken)
        {
            //set maxConcurrentUploads up to 2 untill figure out how to use WinHttpHandler.MaxConnectionsPerServer modify DefaultConnectionLimit
            int maxConcurrentUploads = Math.Min(Environment.ProcessorCount, 2);
            //context.Output($"Max Concurrent Uploads {maxConcurrentUploads}");

            IEnumerable<String> files;
            if (File.Exists(source))
            {
                files = new List<String>() { source };
                _sourceParentDirectory = Path.GetDirectoryName(source);
            }
            else
            {
                files = Directory.EnumerateFiles(source, "*", SearchOption.AllDirectories);
                _sourceParentDirectory = source.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            }

            context.Output(StringUtil.Loc("TotalUploadFiles", files.Count()));
            foreach (var file in files)
            {
                _fileUploadQueue.Enqueue(file);
            }

            using (_uploadCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
            {
                List<Task> allRunningTasks = new List<Task>();
                // start reporting task to keep tracking upload progress.
                allRunningTasks.Add(ReportingAsync(context, files.Count(), _uploadCancellationTokenSource.Token));

                // start parallel upload task.
                for (int i = 0; i < maxConcurrentUploads; i++)
                {
                    allRunningTasks.Add(ParallelUploadAsync(context, i, _uploadCancellationTokenSource.Token));
                }

                // the only expected type of exception will throw from both parallel upload task and reporting task is OperationCancelledException.
                try
                {
                    await Task.WhenAll(allRunningTasks);
                }
                catch (OperationCanceledException)
                {
                    // throw aggregate exception for all non-operationcancelexception we catched during file upload.
                    if (_exceptionsDuringFileUpload.Count > 0)
                    {
                        throw new AggregateException(_exceptionsDuringFileUpload).Flatten();
                    }

                    throw;
                }
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:56,代码来源:FileContainerServer.cs

示例11: OwnerData

 /// <summary>
 /// Создает экземпляр класса
 /// </summary>
 /// <param name="address">Адрес</param>
 /// <param name="id">Код</param>
 /// <param name="inn">ИНН</param>
 /// <param name="kpp">КПП</param>
 /// <param name="name">Наименование</param>
 /// <param name="section">Номер секции ФР</param>
 /// <param name="warrant">Номер свидетельства ИП</param>
 public OwnerData(String id, String name, String address, String inn, String kpp,
     String warrant, Int32 section)
 {
     _id = id.TrimEnd();
     _name = name.TrimEnd();
     _address = address.TrimEnd();
     _inn = inn.TrimEnd();
     _kpp = kpp.TrimEnd();
     _warrant = warrant.TrimEnd();
     _section = section;
 }
开发者ID:Dennis-Petrov,项目名称:Cash,代码行数:21,代码来源:OwnerData.cs

示例12: Combine

        /// <summary>
        /// Combines several path elements
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static String Combine(String left, String right)
        {
            // remove delimiter
            right = right.TrimStart(Delimiter);
            left = left.TrimEnd(Delimiter);

            // build the path
            if (right.Length == 0)
                return left;
            else
                return left + Delimiter + right;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:18,代码来源:PathHelper.cs

示例13: fromJSON

        public Dictionary<String, String> fromJSON(String json)
        {
            Dictionary<String, String> dict = new Dictionary<String, String>();

            Char[] splits = new Char[1];
            splits[0] = ',';

            if (!String.IsNullOrEmpty(json))
            {
                json = json.Trim();

                // Remove leading and trailing breakets
                if (json.StartsWith("{"))
                {
                    json = json.Remove(0, 1);
                    json = json.TrimStart();
                }
                if (json.EndsWith("}"))
                {
                    json = json.Remove(json.Length - 1);
                    json = json.TrimEnd();
                }

                String[] jsonItems = json.Split(splits, StringSplitOptions.RemoveEmptyEntries);

                // iterate all comma-separeted key-value-pairs
                for (int i = 0; i < jsonItems.Length; i++)
                {
                    String currentPart = jsonItems[i];
                    // check if it's a 'real' item-separator or maybe a comma inside a 'marked' string
                    if (checkForConsistentQuotes(currentPart) && currentPart.Contains(":"))
                    {
                        processKeyValuePair(dict, currentPart);
                    }
                    // we splitted inside a string, so do some error-handling
                    else if (i < jsonItems.Length - 1)
                    {
                        // add upcoming parts as long as we do not have a 'working' part
                        do
                        {
                            i++;
                            currentPart += "," + jsonItems[i];
                        }
                        while (!(checkForConsistentQuotes(currentPart) && currentPart.Contains(":")));

                        processKeyValuePair(dict, currentPart);
                    }
                }
            }

            return dict;
        }
开发者ID:pdiegmann,项目名称:net-reaktor,代码行数:52,代码来源:JSONConverter.cs

示例14: PathCombine

		public String PathCombine(String path1, String path2) {
			path1 = path1.TrimEnd("/\\".ToCharArray());
			path2 = path2.TrimStart("/\\".ToCharArray());
			if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
				path1 = path1.Replace("/","\\");
				path2 = path2.Replace("/","\\");
			}

			if(string.IsNullOrWhiteSpace(path1) || string.IsNullOrEmpty(path1))
				return path2;
			else
				return String.Format("{0}{1}{2}",path1,Path.DirectorySeparatorChar,path2);
		}
开发者ID:Meticulus,项目名称:tactical,代码行数:13,代码来源:DataAccessLayer.cs

示例15: GetBytes

 public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
 {
     var str = new String(chars);
     str = str.Replace(" ", "");
     for(int i = charIndex ; i < charIndex + str.Length ; i += 2)
     {
         var charOffset = i - charIndex;
         var byteString = new String(new char[] { str[i], str[i + 1] });
         var b = byte.Parse(byteString.TrimEnd(), NumberStyles.HexNumber);
         bytes[byteIndex + charOffset / 2] = b;
     }
     return str.Length / 2;
 }
开发者ID:NicolasDorier,项目名称:userassist,代码行数:13,代码来源:BytesEncoding.cs


注:本文中的System.String.TrimEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。