本文整理汇总了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);
}
示例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";
}
示例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";
}
}
}
示例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
}
}
示例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;
}
示例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));
}
}