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


C# String.ToUpperInvariant方法代码示例

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


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

示例1: GetBytesFromHexString

        /// <summary>
        /// <para>Returns a byte array from a string representing a hexadecimal number.</para>
        /// </summary>
        /// <param name="hexadecimalNumber">
        /// <para>The string containing a valid hexadecimal number.</para>
        /// </param>
        /// <returns><para>The byte array representing the hexadecimal.</para></returns>
        public static Byte[] GetBytesFromHexString(String hexadecimalNumber)
        {
            if (hexadecimalNumber == null) throw new ArgumentNullException("hexadecimalNumber");

            var sb = new StringBuilder(hexadecimalNumber.ToUpperInvariant());
            if (sb[0].Equals('0') && sb[1].Equals('X'))
            {
                sb.Remove(0, 2);
            }

            if (sb.Length % 2 != 0)
            {
                throw new ArgumentException("String must represent a valid hexadecimal (e.g. : 0F99DD)");
            }

            var hexBytes = new Byte[sb.Length / 2];
            try
            {
                for (var i = 0; i < hexBytes.Length; i++)
                {
                    var stringIndex = i * 2;
                    hexBytes[i] = Convert.ToByte(sb.ToString(stringIndex, 2), 16);
                }
            }
            catch (FormatException ex)
            {
                throw new ArgumentException("String must represent a valid hexadecimal (e.g. : 0F99DD)", ex);
            }

            return hexBytes;
        }
开发者ID:PowerDMS,项目名称:NContext,代码行数:38,代码来源:CryptographyUtility.cs

示例2: RDFPlainLiteral

 /// <summary>
 /// Default-ctor to build a plain literal with language
 /// </summary>
 public RDFPlainLiteral(String value, String language)
     : this(value)
 {
     if (language            != null && Regex.IsMatch(language, "^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$")) {
         this.Language        = language.ToUpperInvariant();
         this.PatternMemberID = RDFModelUtilities.CreateHash(this.ToString());
     }
 }
开发者ID:mdesalvo,项目名称:RDFSharp,代码行数:11,代码来源:RDFPlainLiteral.cs

示例3: assertRefId

        /// <summary>
        /// Asserts that the refId is in the proper format
        /// </summary>
        /// <param name="refId"></param>
        private void assertRefId(String refId)
        {
            Assert.AreEqual(32, refId.Length, "Length");

            int pos = refId.IndexOf("-");
            Assert.AreEqual(-1, pos, "Dashes");

            // Assert case
            Assert.AreEqual(refId, refId.ToUpperInvariant(), "Case Compare");
        }
开发者ID:rafidzal,项目名称:OpenADK-csharp,代码行数:14,代码来源:UUIDTests.cs

示例4: GenerateCacheObjectThumbnail

        /// <summary>
        /// Generate a thumbnail for a specified file
        /// </summary>
        /// <param name="background">The background color that item will have</param>
        /// <param name="pathToFile">The complete path to the file to open</param>
        /// <returns>The generated thumbnail</returns>
        private static Item GenerateCacheObjectThumbnail(Color background, String pathToFile)
        {
            Item ans = new Item();
            int targetWidth = 128, targetHeight = 128;

            Image temp = null;
            /// Generate the thumbnail depending on the type of file
            if (pathToFile != null)
            {
                if (Constants.AllowedExtensionsImages().Any(pathToFile.ToUpperInvariant().EndsWith))
                {
                    using (FileStream fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                    {
                        using (Image image = Image.FromStream(fs, true, false))
                        {
                            //temp = GenerateThumbnailPhoto(pathToFile);
                            temp = ScaleImage(image, 128, 128);
                            ans.Exif = GetExifFromImage(image);
                        }
                    }
                }
                else
                {
                    using (MemoryStream memStream = new MemoryStream())
                    {
                        FFMpegConverter ffmpeg = new FFMpegConverter();
                        ffmpeg.GetVideoThumbnail(pathToFile, memStream);
                        using (Image image = Image.FromStream(memStream, true, false))
                        {
                            temp = ScaleImage(image, 128, 128);
                        }
                    }
                }
            }

            Image target = new Bitmap(1, 1);
            (target as Bitmap).SetPixel(0, 0, background);
            target = new Bitmap(target, targetWidth, targetHeight);

            using (Graphics g = Graphics.FromImage(target))
            {
                g.Clear(background);
                int x = (targetWidth - temp.Width) / 2;
                int y = (targetHeight - temp.Height) / 2;
                g.DrawImage(temp, x, y);
            }

            ans.Thumbnail = target;

            return ans;
        }
开发者ID:Spesiel,项目名称:Photo-Library,代码行数:57,代码来源:Actions.cs

示例5: ToInvariant

        public static string ToInvariant(this string text)
        {
            List<char> newText = new List<char>();

            foreach (char character in text)
            {
                string temp = new String(new char[] { character });

                if (Char.IsUpper(character)) temp.ToUpperInvariant();
                if (Char.IsLower(character)) temp.ToLowerInvariant();

                foreach (char newchar in temp)
                {
                    newText.Add(newchar);
                    temp.NotNullOrDefault("");
                }
            }

            return new String(newText.ToArray());
        }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:20,代码来源:UtilLang.cs

示例6: RDFLangMatchesFilter

 /// <summary>
 /// Default-ctor to build a filter on the given variable for the given language 
 /// </summary>
 public RDFLangMatchesFilter(RDFVariable variable, String language) {
     if (variable != null) {
         if (language != null) {
             if (language == String.Empty || language == "*" || Regex.IsMatch(language, "^[a-zA-Z]+([\\-][a-zA-Z0-9]+)*$")) {
                     this.Variable = variable;
                     this.Language = language.ToUpperInvariant();
                     this.FilterID = RDFModelUtilities.CreateHash(this.ToString());
             }
             else {
                 throw new RDFQueryException("Cannot create RDFLangMatchesFilter because given \"language\" parameter (" + language + ") does not represent a valid language.");
             }
         }
         else {
             throw new RDFQueryException("Cannot create RDFLangMatchesFilter because given \"language\" parameter is null.");
         }
     }
     else {
         throw new RDFQueryException("Cannot create RDFLangMatchesFilter because given \"variable\" parameter is null.");
     }
 }
开发者ID:Acidburn0zzz,项目名称:RDFSharp,代码行数:23,代码来源:RDFLangMatchesFilter.cs

示例7: GetFilePath

        private String GetFilePath(String fileName)
        {
            if (!fileName.ToUpperInvariant().EndsWith(".VM"))
            {
                fileName += ".vm";
            }

            String virtualPath1 = HttpContext.Current.Server.MapPath(String.Concat("/sites/", this.domainName, "/view/", fileName.Trim('/', '\\')));
            if (File.Exists(virtualPath1))
            {
                return virtualPath1;
            }

            String virtualPath2 = HttpContext.Current.Server.MapPath(String.Concat("/sites/default/view/", fileName.Trim('/', '\\')));
            if (File.Exists(virtualPath2))
            {
                return virtualPath2;
            }

            throw new global::NVelocity.Exception.ResourceNotFoundException(String.Format(CultureInfo.CurrentCulture, "Template '{0}' not found", fileName));
        }
开发者ID:dancecoder,项目名称:NStag-Web-Framework,代码行数:21,代码来源:CustomResourceLoader.cs

示例8: GetPaging

 /// <inheritdoc/>
 public override String GetPaging(String sql, String order, Int32 limit, Int32 offset)
 {
     if (offset > 0)
     {
         if (String.IsNullOrEmpty(order))
             throw new ArgumentException("An order should be specified for paging query.", "order");
         sql = new StringBuilder(sql.Length + order.Length + 9)
             .Append(sql)
             .Append(" ")
             .Append(order)
             .Insert(GetAfterSelectInsertPoint(sql), " TOP " + (limit + offset))
             .ToString();
         String anotherOrderby = order.ToUpperInvariant();
         if (anotherOrderby.Contains(" DESC"))
             anotherOrderby = anotherOrderby.Replace(" DESC", " ASC");
         else if (anotherOrderby.Contains(" ASC"))
             anotherOrderby = anotherOrderby.Replace(" ASC", " DESC");
         else
             anotherOrderby += " DESC";
         // NOTE This may not work properly when the total count of records < (limit + offset)
         return new StringBuilder("SELECT * FROM (SELECT top ")
             .Append(limit)
             .Append(" * FROM (")
             .Append(sql)
             .Append(") t1 ")
             .Append(anotherOrderby)
             .Append(") t2 ")
             .Append(order)
             .ToString();
     }
     else
     {
         return new StringBuilder(sql.Length + (order == null ? 0 : order.Length) + 9)
             .Append(sql)
             .Append(" ")
             .Append(order)
             .Insert(GetAfterSelectInsertPoint(sql), " TOP " + limit)
             .ToString();
     }
 }
开发者ID:wyerp,项目名称:EasyDb.NET,代码行数:41,代码来源:SQLServerDialect.cs

示例9: ToNumber

        public static String ToNumber(String raw)
        {
            if (String.IsNullOrWhiteSpace(raw))
                return "";
            else
                raw = raw.ToUpperInvariant();

            var newNumber = new StringBuilder();
            foreach (var c in raw)
            {
                if (" -0123456789".Contains(c))
                    newNumber.Append(c);
                else
                {
                    var result = TranslateToNumber(c);
                    if (result != null)
                        newNumber.Append(result);
                }
                    //ohterwise a nonnumeric char is skipped
            }
            return newNumber.ToString();
        }
开发者ID:Janekdererste,项目名称:Phoneword,代码行数:22,代码来源:PhonewordTranslator.cs

示例10: ParseImportance

        /// <summary>
        /// Parses an ImportanceType from a given Importance header value.
        /// </summary>
        /// <param name="headerValue">The value to be parsed</param>
        /// <returns>A <see cref="MailPriority"/>. If the <paramref name="headerValue"/> is not recognized, Normal is returned.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="headerValue"/> is <see langword="null"/></exception>
        public static MailPriority ParseImportance(String headerValue)
        {
            if (headerValue == null)
                throw new ArgumentNullException("headerValue");

            switch (headerValue.ToUpperInvariant())
            {
                case "5":
                case "HIGH":
                    return MailPriority.High;

                case "3":
                case "NORMAL":
                    return MailPriority.Normal;

                case "1":
                case "LOW":
                    return MailPriority.Low;

                default:
                    return MailPriority.Normal;
            }
        }
开发者ID:nolith,项目名称:internetpack,代码行数:29,代码来源:HeaderFieldParser.cs

示例11: TryParseScriptLine

        /// <summary>Try to parse a script line into commands and arguments</summary>
        /// <param name="line">The line to parse</param>
        /// <param name="commandData">A <seealso cref="CommandData"/> object with commands and keystrokes</param>
        /// <returns>true on success, false on failure, CommandData will be null for commands not requiring data to be sent</returns>        
        public static bool TryParseScriptLine(String line, out CommandData commandData)
        {
            commandData = null;
            if (string.IsNullOrEmpty(line)
                || line.StartsWith("#")) // a comment line, ignore
            {
                return false;
            }


            string command = string.Empty;
            string args = string.Empty;

            int index = line.IndexOf(' ');
            if (index > 0)
            {
                command = line.Substring(0, index);
                args = line.Substring(index + 1).TrimEnd();
            }
            else
            {
                command = line.ToUpperInvariant().TrimEnd();
            }

            // lookup command and execute action associated with it.                
            Func<String, CommandData> spslCommand = MatchCommand(command);
            if (spslCommand != null)
            {
                commandData = spslCommand(args);
                return true;
            }
            else
            {
                Log.WarnFormat("Command {0} Not Supported", command);
                return false;
            }
        }
开发者ID:mesenger,项目名称:superputty,代码行数:41,代码来源:Spsl.cs

示例12: RedrawWindow

    private void RedrawWindow(User32.RECT rect) { }// => User32.InvalidateRect(this.LVHandle, ref rect, false);

    /// <summary>
    /// Returns the index of the first item whose display name starts with the search string.
    /// </summary>
    /// <param name="search">     The string for which to search for. </param>
    /// <param name="startindex">
    /// The index from which to start searching. Enter '0' to search all items.
    /// </param>
    /// <returns> The index of an item within the list view. </returns>
    private Int32 GetFirstIndexOf(String search, Int32 startindex) {
      Int32 i = startindex;
      while (true) {
        if (i >= Items.Count)
          return -1;
        else if (Items[i].DisplayName.ToUpperInvariant().StartsWith(search.ToUpperInvariant()))
          return i;
        else
          i++;
      }
    }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:21,代码来源:ShellViewEx.cs

示例13: BuildBackgroundColorSpan

		/*public override long GetItemId (int position)
		{
			return _Posts [position].Id;
		}*/
		public static SpannableString BuildBackgroundColorSpan(SpannableString spannableString,
			String text, String searchString, Color color) {

			int indexOf = text.ToUpperInvariant().IndexOf(searchString.ToUpperInvariant());

			try {
				spannableString.SetSpan(new BackgroundColorSpan(color), indexOf,
					(indexOf + searchString.Length),SpanTypes.ExclusiveExclusive);
			} catch (Exception e) {

			}


			return spannableString;
		}
开发者ID:takigava,项目名称:pikabu,代码行数:19,代码来源:PostViewAdapter.cs

示例14: CanParseDccCommand

 /// <summary>
 /// Determines if the message
 /// </summary>
 /// <param name="command"></param>
 /// <returns></returns>
 public virtual Boolean CanParseDccCommand( String command )
 {
     if ( String.IsNullOrEmpty( command ) )
     {
         return false;
     }
     return ( DccCommand.ToUpperInvariant().EndsWith( command.ToUpperInvariant(), StringComparison.Ordinal ) );
 }
开发者ID:WhiteCoreSim,项目名称:WhiteCore-Optional-Modules,代码行数:13,代码来源:DccAcceptRequestMessage.cs

示例15: ParseCharsetToEncoding

		/// <summary>
		/// Parse a character set into an encoding.
		/// </summary>
		/// <param name="characterSet">The character set to parse</param>
		/// <returns>An encoding which corresponds to the character set</returns>
		/// <exception cref="ArgumentNullException">If <paramref name="characterSet"/> is <see langword="null"/></exception>
		public static Encoding ParseCharsetToEncoding(String characterSet)
		{
			if (characterSet == null)
				throw new ArgumentNullException("characterSet");

			String charSetUpper = characterSet.ToUpperInvariant();
			if (charSetUpper.Contains("WINDOWS") || charSetUpper.Contains("CP"))
			{
				// It seems the character set contains an codepage value, which we should use to parse the encoding
				charSetUpper = charSetUpper.Replace("CP", ""); // Remove cp
				charSetUpper = charSetUpper.Replace("WINDOWS", ""); // Remove windows
				charSetUpper = charSetUpper.Replace("-", ""); // Remove - which could be used as cp-1554

				// Now we hope the only thing left in the characterSet is numbers.
				Int32 codepageNumber = Int32.Parse(charSetUpper, CultureInfo.InvariantCulture);

				return Encoding.GetEncoding(codepageNumber);
			}

			// Some emails incorrectly specify the encoding to be utf8 - but it has to be utf-8
			if (characterSet.Equals("utf8", StringComparison.InvariantCultureIgnoreCase))
				characterSet = "utf-8";

			// It seems there is no codepage value in the characterSet. It must be a named encoding
			return Encoding.GetEncoding(characterSet);
		}
开发者ID:remobjects,项目名称:internetpack,代码行数:32,代码来源:Utility.cs


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