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


C# this.Contains方法代码示例

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


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

示例1: Intersects

 public static bool Intersects(this ITimeInterval time1, ITimeInterval time2)
 {
     return
         time1 != null && time2 != null &&
         (time1.Contains(time2.From) ||
         time1.Contains(time2.To));
 }
开发者ID:Ce-Ma-S,项目名称:SenseLab.old,代码行数:7,代码来源:TimeHelper.cs

示例2: ToStringArray

        /// <summary>
        /// Converts <paramref name="folderStructureOptions"/> to string array
        /// </summary>
        /// <param name="folderStructureOptions">Folder structure retrieve options</param>
        /// <returns>String array representation of <paramref name="folderStructureOptions"/></returns>
        public static string[] ToStringArray(this RetrieveFolderStructureOptions folderStructureOptions)
        {
            List<string> result = new List<string>(3);

            if(folderStructureOptions.Contains(RetrieveFolderStructureOptions.NoFiles))
            {
                result.Add("nofiles");
            }

            if (folderStructureOptions.Contains(RetrieveFolderStructureOptions.NoZip))
            {
                result.Add("nozip");
            }

            if (folderStructureOptions.Contains(RetrieveFolderStructureOptions.OneLevel))
            {
                result.Add("onelevel");
            }

            if (folderStructureOptions.Contains(RetrieveFolderStructureOptions.Simple))
            {
                result.Add("simple");
            }

            return result.ToArray();
        }
开发者ID:CoderDennis,项目名称:box-csharp-sdk,代码行数:31,代码来源:RetrieveFolderStructureOptions.cs

示例3: HasRouteKey

 public static bool HasRouteKey(this string routeUrl, string routeKey)
 {
     return
         routeUrl.Contains("{" + routeKey + "}")
         ||
         routeUrl.Contains("{" + "*" + routeKey + "}");
 }
开发者ID:chiganock,项目名称:VtecTeamFlasher,代码行数:7,代码来源:RoutingExtensions.cs

示例4: GetDoubleValueFromStringEntry

        public static double GetDoubleValueFromStringEntry(this string val)
        {
            // Todo, felkollar
            var cultureToUse = System.Threading.Thread.CurrentThread.CurrentCulture;
            if (string.IsNullOrEmpty(val))
            {
                return 0.0;
            }

            if (val.Contains("."))
            {
                cultureToUse = new CultureInfo("en-US");
            }
            else if (val.Contains(","))
            {
                cultureToUse = new CultureInfo("sv-SE");
            }

            var cleanVal = val.Trim()
                .Replace(" ", string.Empty)
                .Replace(":", string.Empty)
                .Replace(";", string.Empty)
                .Replace(":", string.Empty);

            double tempd;
            return double.TryParse(cleanVal, NumberStyles.Number, cultureToUse, out tempd)
                       ? Math.Round(tempd, 2)
                       : 0.0;
        }
开发者ID:perragradeen,项目名称:webbankbudgeter,代码行数:29,代码来源:NumberFunctions.cs

示例5: GetStringBetween

    public static string GetStringBetween(
        this string input, string startString, string endString, int startFrom = 0)
    {
        input = input.Substring(startFrom);
        startFrom = 0;
        if (!input.Contains(startString) || !input.Contains(endString))
        {
            return string.Empty;
        }

        var startPosition = 
            input.IndexOf(startString, startFrom, StringComparison.Ordinal) + startString.Length;
        if (startPosition == -1)
        {
            return string.Empty;
        }

        var endPosition = input.IndexOf(endString, startPosition, StringComparison.Ordinal);
        if (endPosition == -1)
        {
            return string.Empty;
        }

        return input.Substring(startPosition, endPosition - startPosition);
    }
开发者ID:KostaDinkov,项目名称:SoftUni,代码行数:25,代码来源:StringExtensions.cs

示例6: RemoveBetween

        /// <summary>
        /// http://stackoverflow.com/a/39096603/128662
        /// </summary>
        public static string RemoveBetween(this string rawString, char enter, char exit)
        {
            if (rawString.Contains(enter) && rawString.Contains(exit))
            {
                int substringStartIndex = rawString.IndexOf(enter) + 1;
                int substringLength = rawString.LastIndexOf(exit) - substringStartIndex;

                string replaced = rawString;
                if (substringLength > 0 && substringLength > substringStartIndex)
                {
                    string substring = rawString.Substring(substringStartIndex, substringLength).RemoveBetween(enter, exit);
                    if (substring.Length != substringLength) // This would mean that letters have been removed
                    {
                        replaced = rawString.Remove(substringStartIndex, substringLength).Insert(substringStartIndex, substring);
                    }
                }

                //Source: http://stackoverflow.com/a/1359521/3407324
                Regex regex = new Regex(string.Format("\\{0}.*?\\{1}", enter, exit));
                return new Regex(" +").Replace(regex.Replace(replaced, string.Empty), " ");
            }
            else
            {
                return rawString;
            }
        }
开发者ID:resgroup,项目名称:nimrod,代码行数:29,代码来源:StringExtensions.cs

示例7: Contains

 public static bool Contains(this Rect rect, Rect otherRect)
 {
     Vector2 topLeftPoint = new Vector2(otherRect.xMin, otherRect.yMin);
     Vector2 bottomRightPoint = new Vector2(otherRect.xMax, otherRect.yMax);
     //Debug.Log("Rect " + new Vector2(rect.xMax, rect.yMax) + " topLeftPoint " + topLeftPoint + "  bottomRightPoint " + bottomRightPoint);
     return rect.Contains(topLeftPoint) && rect.Contains(bottomRightPoint);
 }
开发者ID:BigStrongLiu,项目名称:It-is-three-kingdoms-or-Phoenix-sigh,代码行数:7,代码来源:MathUtils.cs

示例8: StemNameBase

    public static string StemNameBase(this string name)
    {
      if (name == null) {
        throw new ArgumentNullException("name");
      }

      if (!name.Contains(" ")) {
        name = name.Replace('_', ' ');
        if (!name.Contains(" ")) {
          name = name.Replace('-', ' ');
        }
        name = respace.Replace(name, " ");
      }
      var ws = name;
      var wsprev = name;
      do {
        wsprev = ws;
        ws = trim.Replace(wsprev.Trim(), " ").Trim();
      }
      while (wsprev != ws);
      if (string.IsNullOrWhiteSpace(ws)) {
        return name;
      }
      return ws;
    }
开发者ID:itsmevix,项目名称:FTT-DLNA,代码行数:25,代码来源:Formatting.cs

示例9: parseRow

		public static dynamic parseRow(this string matchString, string[] columns)
		{
			var defaults = new Dictionary<string, string>()
			{
				{"Event", "Open Play"},
				{"Location", "Courtyard"},
				{"Club", "Courtyard"},
				{"Time", "6am"},
				{"Comments", ""},
			};

			var delimiter = matchString.Contains("\t") ? "\t" : matchString.Contains(",") ? "," : " ";
			var array = matchString.Split(delimiter.ToCharArray(), StringSplitOptions.None);
			//var values = new Dictionary<string, string>();
			dynamic expando = new ExpandoObject();
			var values = (IDictionary<string, object>)expando;

			for (int i = 0; i < array.Length; i++)
			{
				var key = columns[i];
				var value = array[i];
				if (value == "")
					value = defaults[key];
				values.Add(key, value);
			}

			return values;
		}
开发者ID:gbahns,项目名称:Tennis,代码行数:28,代码来源:StructuredMatchParser.cs

示例10: ToCellType

 public static CellType ToCellType(this string battleType)
 {
     return battleType.Contains("sp_midnight") ? CellType.夜戦
         : battleType.Contains("ld_airbattle") ? CellType.空襲戦    //ColorNoからも分かるが、航空戦と誤認しないため
         : battleType.Contains("airbattle") ? CellType.航空戦
         : CellType.None;
 }
开发者ID:Yoctillion,项目名称:BattleInfoPlugin,代码行数:7,代码来源:CellType.cs

示例11: IsBase64

        public static bool IsBase64(this string base64String)
        {
            // Based on http://stackoverflow.com/a/6309439

            // pre-test to check if it's obviously invalid
            // (fast for long values like images and videos)
            if (string.IsNullOrEmpty(base64String) ||
                base64String.Length % 4 != 0 ||
                base64String.Contains(" ") ||
                base64String.Contains("\t") ||
                base64String.Contains("\r") ||
                base64String.Contains("\n"))
            {
                return false;
            }

            // now do the real test
            try
            {
                Convert.FromBase64String(base64String);
                return true;
            }
            catch (FormatException)
            {
                return false;
            }
        }
开发者ID:b3540,项目名称:azure-iot-predictive-maintenance,代码行数:27,代码来源:StringExtensions.cs

示例12: CompareTo

        /// <summary>
        /// Compares to the given value returning true if comparable.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="compareValue">The compare value.</param>
        /// <param name="compareType">Type of the compare.</param>
        /// <returns></returns>
        public static bool CompareTo( this string value, string compareValue, ComparisonType compareType )
        {
            // Evaluate compare types that are not type specific
            switch ( compareType )
            {
                case ComparisonType.Contains: return value.Contains( compareValue );
                case ComparisonType.DoesNotContain: return !value.Contains( compareValue );
                case ComparisonType.StartsWith: return value.StartsWith( compareValue, StringComparison.OrdinalIgnoreCase );
                case ComparisonType.EndsWith: return value.EndsWith( compareValue, StringComparison.OrdinalIgnoreCase );
                case ComparisonType.IsBlank: return string.IsNullOrWhiteSpace( value );
                case ComparisonType.IsNotBlank: return !string.IsNullOrWhiteSpace( value );
                case ComparisonType.RegularExpression: return Regex.IsMatch( value, compareValue );
            }

            // numeric compares
            decimal? decimalValue = value.AsDecimalOrNull();
            decimal? decimalCompareValue = compareValue.AsDecimalOrNull();
            if ( decimalValue.HasValue && decimalCompareValue.HasValue )
            {
                switch ( compareType )
                {
                    case ComparisonType.EqualTo: return decimalValue == decimalCompareValue;
                    case ComparisonType.GreaterThan: return decimalValue.Value > decimalCompareValue.Value;
                    case ComparisonType.GreaterThanOrEqualTo: return decimalValue.Value >= decimalCompareValue.Value;
                    case ComparisonType.LessThan: return decimalValue.Value < decimalCompareValue.Value;
                    case ComparisonType.LessThanOrEqualTo: return decimalValue.Value <= decimalCompareValue.Value;
                    case ComparisonType.NotEqualTo: return decimalValue.Value != decimalCompareValue.Value;
                }
            }

            // date time compares
            DateTime? datetimeValue = value.AsDateTime();
            DateTime? datetimeCompareValue = compareValue.AsDateTime();
            if ( datetimeValue.HasValue && datetimeCompareValue.HasValue )
            {
                switch ( compareType )
                {
                    case ComparisonType.EqualTo: return datetimeValue == datetimeCompareValue;
                    case ComparisonType.GreaterThan: return datetimeValue.Value > datetimeCompareValue.Value;
                    case ComparisonType.GreaterThanOrEqualTo: return datetimeValue.Value >= datetimeCompareValue.Value;
                    case ComparisonType.LessThan: return datetimeValue.Value < datetimeCompareValue.Value;
                    case ComparisonType.LessThanOrEqualTo: return datetimeValue.Value <= datetimeCompareValue.Value;
                    case ComparisonType.NotEqualTo: return datetimeValue.Value != datetimeCompareValue.Value;
                }
            }

            // string compares
            switch ( compareType )
            {
                case ComparisonType.EqualTo: return value.Equals( compareValue, StringComparison.OrdinalIgnoreCase );
                case ComparisonType.GreaterThan: return value.CompareTo( compareValue ) > 0;
                case ComparisonType.GreaterThanOrEqualTo: return value.CompareTo( compareValue ) >= 0;
                case ComparisonType.LessThan: return value.CompareTo( compareValue ) < 0;
                case ComparisonType.LessThanOrEqualTo: return value.CompareTo( compareValue ) <= 0;
                case ComparisonType.NotEqualTo: return !value.Equals( compareValue, StringComparison.OrdinalIgnoreCase );
            }

            return false;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:66,代码来源:ReportingExtensions.cs

示例13: SubstringRange

 public static string SubstringRange(this string s, char start, char end)
 {
     if (s.Contains(start) && s.Contains(end))
     {
         return s.Substring(s.IndexOf(start), s.IndexOf(end) - s.IndexOf(start) + 1);
     }
     else return "";
 }
开发者ID:himanshugoel2797,项目名称:MSIL2CPP,代码行数:8,代码来源:Helpers.cs

示例14: RemoveRange

 public static string RemoveRange(this string s, char start, char end)
 {
     if (s.Contains(start) && s.Contains(end))
     {
         return s.Remove(s.IndexOf(start), s.IndexOf(end) - s.IndexOf(start) + 1);
     }
     else return s;
 }
开发者ID:himanshugoel2797,项目名称:MSIL2CPP,代码行数:8,代码来源:Helpers.cs

示例15: IntersectsLine

 public static bool IntersectsLine( this Rect r, Vector2 p1, Vector2 p2 )
 {
     return LineIntersectsLine ( p1, p2, new Vector2 ( r.x, r.y ), new Vector2 ( r.x + r.width, r.y ) ) ||
            LineIntersectsLine ( p1, p2, new Vector2 ( r.x + r.width, r.y ), new Vector2 ( r.x + r.width, r.y + r.height ) ) ||
            LineIntersectsLine ( p1, p2, new Vector2 ( r.x + r.height, r.y + r.height ), new Vector2 ( r.x, r.y + r.height ) ) ||
            LineIntersectsLine ( p1, p2, new Vector2 ( r.x, r.y + r.height ), new Vector2 ( r.x, r.y ) ) ||
            ( r.Contains ( p1 ) && r.Contains ( p2 ) );
 }
开发者ID:apautrot,项目名称:gdp9,代码行数:8,代码来源:Vector3ExtensionMethods.cs


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