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


C# String.Contains方法代码示例

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


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

示例1: AppendQuoted

        private static void AppendQuoted(this StringBuilder sb, String s)
        {
            bool needsQuoting = false;
            const char quoteChar = '\"';

            //@todo: App-compat: You can use double or single quotes to quote a name, and Fusion (or rather the IdentityAuthority) picks one
            // by some algorithm. Rather than guess at it, I'll just use double-quote consistently.
            if (s != s.Trim() || s.Contains("\"") || s.Contains("\'"))
                needsQuoting = true;

            if (needsQuoting)
                sb.Append(quoteChar);

            for (int i = 0; i < s.Length; i++)
            {
                bool addedEscape = false;
                foreach (KeyValuePair<char, String> kv in AssemblyNameLexer.EscapeSequences)
                {
                    String escapeReplacement = kv.Value;
                    if (!(s[i] == escapeReplacement[0]))
                        continue;
                    if ((s.Length - i) < escapeReplacement.Length)
                        continue;
                    String prefix = s.Substring(i, escapeReplacement.Length);
                    if (prefix == escapeReplacement)
                    {
                        sb.Append('\\');
                        sb.Append(kv.Key);
                        addedEscape = true;
                    }
                }

                if (!addedEscape)
                    sb.Append(s[i]);
            }

            if (needsQuoting)
                sb.Append(quoteChar);
        }
开发者ID:noahfalk,项目名称:corert,代码行数:39,代码来源:AssemblyNameHelpers.cs

示例2: Format

        //
        // This is a workaround to prevent crucial information being lost when compiling console apps using the retail ILC.
        // This combination turns rich error messages from the framework into resource keys without the substitution strings.
        // We'll detect this case here and append the substitution string manually.
        //
        private static String Format(String resourceMessage, Object parameter)
        {
            if (resourceMessage.Contains("{0}"))
                return SR.Format(resourceMessage, parameter);

            // If the rich exception message was eaten by the IL2IL transform, make sure the resulting message
            // has a link pointing the user towards the .NET Native debugging guide. These get normally appended
            // to the restricted message by the transform, but the pattern here is not recognized by the rewriter.
            // At this point we know the message doesn't come from resources (because message == resource key), so
            // we can't do much to make this localizable.
            return resourceMessage + ": " + parameter + ". For more information, visit http://go.microsoft.com/fwlink/?LinkId=623485";
        }
开发者ID:kyulee1,项目名称:corert,代码行数:17,代码来源:MissingMetadataExceptionCreator.cs

示例3: Item

            public Item(ExiledToolkit.Models.PathOfExileObjects.Item pItem)
            {
                PropertyNames = new List<string>();
                SkillGemTypes = new List<SkillTypes>();
                Statistics = new Dictionary<Stats, double>();
                MinimumDamage = new Dictionary<DamageTypes, int>();
                MaximumDamage = new Dictionary<DamageTypes, int>();

                JSONDefinition = JsonConvert.SerializeObject(pItem);
                Name = pItem.name;
                Type = pItem.typeLine;
                Description = pItem.descrText;
                BaseType = String.Empty;

                //Parse through properties
                if (pItem.properties != null)
                {
                    foreach (ExiledToolkit.Models.PathOfExileObjects.Property fProp in pItem.properties)
                    {
                        EvaluateProperty(fProp);
                    }
                }
                if (pItem.requirements != null)
                {
                    // parse them requirements
                }
                if (pItem.implicitMods != null)
                {
                    foreach (String mod in pItem.implicitMods)
                    {
                        EvaluateMod(mod);
                    }
                }
                if (pItem.explicitMods != null)
                {
                    foreach (String mod in pItem.explicitMods)
                    {
                        EvaluateMod(mod);
                    }
                }
                if (BaseType == String.Empty)
                {
                    if (Type.Contains("Belt"))
                    {
                        BaseType = "Belt";
                    }
                    else if (Type.Contains("Ring"))
                    {
                        BaseType = "Ring";
                    }
                    else if (Type.Contains("Amulet"))
                    {
                        BaseType = "Amulet";
                    }
                    else if (Type.Contains("Flask"))
                    {
                        BaseType = "Flask";
                    }
                    else if (Description != null && Description.Length > 0)
                    {
                        BaseType = "Currency";
                    }
                    else
                    {
                        BaseType = "Armor";
                    }
                }
            }
开发者ID:jarneson,项目名称:exiled-toolkit,代码行数:68,代码来源:ToolkitObjects.cs

示例4: EvaluateMod

 private void EvaluateMod(String lMod)
 {
     if (lMod.StartsWith("Adds"))
     {
         // Probably Damage Mod
     }
     else if (lMod.StartsWith("+"))
     {
         // Flat bonus to something or Life/Mana on hit/kill
     }
     else if (lMod.Contains("%"))
     {
         // Percent bonus to something
     }
 }
开发者ID:jarneson,项目名称:exiled-toolkit,代码行数:15,代码来源:ToolkitObjects.cs

示例5: EvaluatePropertyName

 PropertyNameType EvaluatePropertyName(String pName)
 {
     PropertyNameType lType = PropertyNameType.Unknown;
     if (!Enum.TryParse(pName.Replace(" ", "_"), true, out lType))
     {
         // Not a basic Type..
         WeaponTypes temp;
         if (Enum.TryParse(pName.Replace(" ", "_"), true, out temp))
         {
             // weapon..
             lType = PropertyNameType.Weapon;
         }
         else
         {
             // maybe it's a spell
             if (pName.Contains(','))
             {
                 lType = PropertyNameType.SkillGem;
                 String[] tokens = pName.Split(',');
                 foreach (String s in tokens)
                 {
                     SkillTypes type = SkillTypes.Unknown;
                     if (Enum.TryParse(s, out type))
                     {
                         SkillGemTypes.Add(type);
                     }
                 }
             }
             else
             {
                 // It may still be a spell..
                 SkillTypes type = SkillTypes.Unknown;
                 if (Enum.TryParse(pName, out type))
                 {
                     lType = PropertyNameType.SkillGem;
                     SkillGemTypes.Add(type);
                 }
                 else
                 {
                     lType = PropertyNameType.Unknown;
                 }
             }
         }
     }
     return lType;
 }
开发者ID:jarneson,项目名称:exiled-toolkit,代码行数:46,代码来源:ToolkitObjects.cs

示例6: UrlEncodeIDNSafe

        private String UrlEncodeIDNSafe(String url) {
            // Bug 86594: Should not encode the domain part of the url. For example,
            // http://Übersite/Überpage.aspx should only encode the 2nd Ü.
            // To accomplish this we must separate the scheme+host+port portion of the url from the path portion,
            // encode the path portion, then reconstruct the url.
            Debug.Assert(!url.Contains("?"), "Querystring should have been stripped off.");

            string schemeAndAuthority;
            string path;
            string queryAndFragment;
            bool isValidUrl = UriUtil.TrySplitUriForPathEncode(url, out schemeAndAuthority, out path, out queryAndFragment, checkScheme: true);

            if (isValidUrl) {
                // only encode the path portion
                return schemeAndAuthority + HttpEncoderUtility.UrlEncodeSpaces(HttpUtility.UrlEncodeNonAscii(path, Encoding.UTF8)) + queryAndFragment;
            }
            else {
                // encode the entire URL
                return HttpEncoderUtility.UrlEncodeSpaces(HttpUtility.UrlEncodeNonAscii(url, Encoding.UTF8));
            }
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:21,代码来源:HttpResponse.cs


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