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


C# IList.IndexOf方法代码示例

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


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

示例1: UpdateDiagram

        public static void UpdateDiagram(IList<StateFunction> list, StateFunction fn)
        {
            if (highlightedFn != null)
            {
                string mOld = string.Empty;
                foreach (var mov in highlightedFn.Movement)
                {
                    mOld += mov;
                }
                var sOld = string.Format("({0}, {1}) = ({2}, {3}, {4})", highlightedFn.CurrentState, highlightedFn.Read, highlightedFn.NewState, highlightedFn.Write, mOld);
                //TODO
                Tools.Write(Console.WindowWidth - 50, list.IndexOf(highlightedFn), sOld);
            }

            ConsoleColor f = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;

            string m = string.Empty;
            foreach (var mov in fn.Movement)
            {
                m += mov;
            }
            var s = string.Format("({0}, {1}) = ({2}, {3}, {4})", fn.CurrentState, fn.Read, fn.NewState, fn.Write, m);
            Tools.Write(Console.WindowWidth - 50, list.IndexOf(fn), s);

            highlightedFn = fn;

            Console.ForegroundColor = f;
        }
开发者ID:tbandixen,项目名称:Turing,代码行数:30,代码来源:Tools.cs

示例2: FindTwoSum

		public static Tuple<int, int> FindTwoSum(IList<int> list, int sum)
		{
			var result = from n1 in list
				from n2 in list
					where n1 + n2 == sum
				select new Tuple<int, int>(list.IndexOf(n1), list.IndexOf(n2));
			return result.FirstOrDefault();
		}
开发者ID:nitrix-reloaded,项目名称:CSharpSamples,代码行数:8,代码来源:TwoSum.cs

示例3: Swap

 public void Swap(IList<ITile> tiles, ITile first, ITile second)
 {
     int firstIndex = tiles.IndexOf(first);
     int secondIndex = tiles.IndexOf(second);
     if (firstIndex == -1 || secondIndex == -1)
         return;
     tiles[firstIndex] = second;
     tiles[secondIndex] = first;
 }
开发者ID:djpereira,项目名称:Caliburn.Micro-TileOrderMVVM,代码行数:9,代码来源:TileService.cs

示例4: GetArguments

        protected IDictionary<string, string> GetArguments(IList<string> args)
        {
            args = args.Select(arg => arg.Replace(ARGUMENT_VALUE_PREFIX, string.Empty)).ToList();

            var indexes = args.Where(a => a.StartsWith(ARGUMENT_PREFIX)).Select(arg => new { Key = arg, Index = args.IndexOf(arg) });

            return
                (from arg in args.Where(a => a.StartsWith(ARGUMENT_PREFIX))
                let index = args.IndexOf(arg)
                let others = indexes.SkipWhile(a => a.Key != arg).Skip(1)
                let next = others.Any() ? others.First().Index : args.Count
                let val = string.Join(FRAGMENT_DELIMITER, args.Skip(index + 1).Take(next - index - 1).ToArray())
                let cleanedArg = arg.Replace(ARGUMENT_PREFIX, string.Empty)
                select new KeyValuePair<string, string>(cleanedArg, val)).ToDictionary(x => x.Key, x => x.Value);
        }
开发者ID:jamesholcomb,项目名称:Commandr,代码行数:15,代码来源:DefaultCommandSplitter.cs

示例5: SyncTestItemsIList

        public void SyncTestItemsIList(ref IList<TestItem> source, ref IList<TestItem> destination)
        {
            foreach (var item in source)
            {
                var dest = destination.SingleOrDefault(d => d.Id == item.Id);
                if (dest == null)
                {
                    destination.Add(item);
                }
                else
                {
                    if (dest.Sync < item.Sync)
                    {
                         destination[destination.IndexOf(dest)] = item.Clone();
                    }
                }
            }

            foreach (var item in destination)
            {
                var sour = source.SingleOrDefault(s => s.Id == item.Id);
                if (sour == null)
                {
                    source.Add(item);
                }
                else
                {
                    if (sour.Sync < item.Sync)
                    {
                        source[source.IndexOf(sour)] = item.Clone();
                    }
                }
            }
        }
开发者ID:Perpetuum1101,项目名称:WordsTest,代码行数:34,代码来源:Manager.cs

示例6: SrotingButtons

    public static bool SrotingButtons(object currentObject, IList ObjectsList)
    {
        int ObjectIndex = ObjectsList.IndexOf(currentObject);
        if(ObjectIndex == 0) {
            GUI.enabled = false;
        }

        bool up 		= GUILayout.Button("↑", EditorStyles.miniButtonLeft, GUILayout.Width(20));
        if(up) {
            object c = currentObject;
            ObjectsList[ObjectIndex]  		= ObjectsList[ObjectIndex - 1];
            ObjectsList[ObjectIndex - 1] 	=  c;
        }

        if(ObjectIndex >= ObjectsList.Count -1) {
            GUI.enabled = false;
        } else {
            GUI.enabled = true;
        }

        bool down 		= GUILayout.Button("↓", EditorStyles.miniButtonMid, GUILayout.Width(20));
        if(down) {
            object c = currentObject;
            ObjectsList[ObjectIndex] =  ObjectsList[ObjectIndex + 1];
            ObjectsList[ObjectIndex + 1] = c;
        }

        GUI.enabled = true;
        bool r 			= GUILayout.Button("-", EditorStyles.miniButtonRight, GUILayout.Width(20));
        if(r) {
            ObjectsList.Remove(currentObject);
        }

        return r;
    }
开发者ID:Thanhvx-dth,项目名称:SexyPuzzle,代码行数:35,代码来源:SA_EditorTool.cs

示例7: GetDominatedExpressions

        private List<Expression> GetDominatedExpressions(BinaryExpression assignment, IList<Expression> blockExpressions)
        {
            int assignmentIndex = blockExpressions.IndexOf(assignment);
            Expression assignedValue = assignment.Right;
            List<Expression> result = new List<Expression>();
            //ExpressionTreeVisitor etv = new ExpressionTreeVisitor();
            //IEnumerable<VariableReference> variablesUsed = etv.GetUsedVariables(assignedValue);
            //ICollection<ParameterReference> argumentsUsed = etv.GetUsedArguments(assignedValue);

            /// If this is some form of autoassignment
            if (ChangesAssignedExpression(assignment.Right, assignment.Left, assignment.Left))
            {
                return result;
            }

            for (int i = assignmentIndex + 1; i < blockExpressions.Count; i++)
            {
                //TODO: Add breaks and checks
                Expression currentExpression = blockExpressions[i];
                if (ChangesAssignedExpression(currentExpression, assignedValue, assignment.Left))
                {
                    break;
                }
                result.Add(blockExpressions[i]);
            }
            return result;
        }
开发者ID:is00hcw,项目名称:JustDecompileEngine,代码行数:27,代码来源:ExpressionPropagationStep.cs

示例8: ParseRealization

 private void ParseRealization(IList<Double> realization)
 {
     Double repeatedValue = realization.Last(); // last value it's the same as cycle start value
     Int32 cycleStartIndex = realization.IndexOf(repeatedValue);
     Appendix = realization.Take(cycleStartIndex).ToList();
     Cycle = realization.Skip(cycleStartIndex).Take(realization.Count - cycleStartIndex - 1).ToList();
 }
开发者ID:romannort,项目名称:Modeling.LabOne,代码行数:7,代码来源:StatisticsResults.cs

示例9: GuerillaPreProcessMethod

 protected static void GuerillaPreProcessMethod(BinaryReader binaryReader, IList<tag_field> fields)
 {
     var index = (from field in fields
                  where field.Name == "Object Data"
                  select fields.IndexOf(field)).Single();
     fields.Insert(++index, new tag_field() { type = field_type._field_pad, Name = "indexer", definition = 4 });
 }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:7,代码来源:Scenario.Code.cs

示例10: MultilayerPerceptron

        public MultilayerPerceptron(int numInputs, int numOutputs, IList<int> hiddenLayerSizes)
        {
            if (numInputs <= 0)
                throw new NeuralNetworkException($"Argument {nameof(numInputs)} must be positive; was {numInputs}.");

            if (numOutputs <= 0)
                throw new NeuralNetworkException($"Argument {nameof(numOutputs)} must be positive; was {numOutputs}.");

            if (hiddenLayerSizes == null || !hiddenLayerSizes.Any())
                throw new NeuralNetworkException($"Argument {nameof(hiddenLayerSizes)} cannot be null or empty.");

            if (hiddenLayerSizes.Any(h => h <= 0))
            {
                var badSize = hiddenLayerSizes.First(h => h <= 0);
                var index = hiddenLayerSizes.IndexOf(badSize);
                throw new NeuralNetworkException($"Argument {nameof(hiddenLayerSizes)} must contain only positive " +
                                                $"values; was {badSize} at index {index}.");
            }

            NumInputs = numInputs;
            NumOutputs = numOutputs;
            HiddenLayerSizes = hiddenLayerSizes.ToArray();

            Weights = new double[hiddenLayerSizes.Count + 1][];

            for (var i = 0; i < hiddenLayerSizes.Count + 1; i++)
            {
                if (i == 0)
                    Weights[i] = new double[(numInputs + 1) * hiddenLayerSizes[0]];
                else if (i < hiddenLayerSizes.Count)
                    Weights[i] = new double[(hiddenLayerSizes[i-1] + 1) * hiddenLayerSizes[i]];
                else
                    Weights[i] = new double[(hiddenLayerSizes[hiddenLayerSizes.Count - 1] + 1) * numOutputs];
            }
        }
开发者ID:ikhramts,项目名称:NNX,代码行数:35,代码来源:MultilayerPerceptron.cs

示例11: getInstruction

 static Instruction getInstruction(IList<Instruction> instrs, Instruction source, int displ)
 {
     int sourceIndex = instrs.IndexOf(source);
     if (sourceIndex < 0)
         throw new ApplicationException("Could not find source instruction");
     return instrs[sourceIndex + displ];
 }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:7,代码来源:CsvmToCilMethodConverter.cs

示例12: CommandExecute

        /// <summary>
        /// FPS command implementation.
        /// </summary>
        private void CommandExecute(IDebugCommandHost host, string command, IList<string> arguments)
        {
            foreach (string arg in arguments) { arg.ToLower(); }

            if (arguments.Contains("list")) { ShowList(); }

            if (arguments.Contains("open"))
            {
                int index = arguments.IndexOf("open");
                string sceneToOpen = arguments[index + 1];

                if (sceneManager.ContainsScene(sceneToOpen))
                {
                    // activate the selected scene
                    sceneManager.ActivateScene(sceneToOpen);
                }
            }

            if (arguments.Contains("close"))
            {
                int index = arguments.IndexOf("close");
                string sceneToClose = arguments[index + 1];

                if (sceneManager.ContainsScene(sceneToClose))
                {
                    sceneManager.ExitScene(sceneToClose);
                }
            }
            // TODO: allow loading and disposing of scenes
        }
开发者ID:fidgetwidget,项目名称:SmallGalaxy_Engine,代码行数:33,代码来源:SceneManagerUtils.cs

示例13: GetValue

 public static void GetValue(ImportExportItem data, IList<string> rowData, IList<string> columnNames)
 {
     foreach (var item in typeof(ImportExportItem).GetProperties())
     {
         item.SetValue(data, ConvertType(item.PropertyType, rowData[columnNames.IndexOf(item.Name.ToLower())]), null);
     }
 }
开发者ID:MisterTobi,项目名称:restaurant-cafe,代码行数:7,代码来源:ImportExportItem.cs

示例14: ToComboItems

        /// <summary>
        /// Convert output combo items list
        /// </summary>
        /// <param name="target">List master code</param>
        /// <param name="selectedValue">Selected value</param>
        /// <returns>List ListItem</returns>
        public static ComboModel ToComboItems(IList<MCode> target, string selectedValue)
        {
            // Local variable declaration
            ComboModel comboModel = null;
            IList<ComboItem> listComboItems = null;

            // Variable initialize
            listComboItems = new List<ComboItem>();
            comboModel = new ComboModel();

            // Get data
            var val = string.Empty;
            foreach (var obj in target)
            {
                var combo = new ComboItem();
                combo.Code = DataHelper.ToString(obj.CodeCd);
                combo.Name = DataHelper.ToString(obj.CodeName);
                if (combo.Code == selectedValue
                    || (DataCheckHelper.IsNull(selectedValue) && target.IndexOf(obj) == 0))
                    val = combo.Code;
                listComboItems.Add(combo);
            }

            // Set value
            comboModel.SeletedValue = val;
            comboModel.ListItems = listComboItems;

            return comboModel;
        }
开发者ID:hieur8,项目名称:web-mbec,代码行数:35,代码来源:MCodeCom.cs

示例15: ValidateOrder

		/// <summary>
		/// Determines if the specified plugin order is valid.
		/// </summary>
		/// <param name="p_lstPlugins">The plugins whose order is to be validated.</param>
		/// <returns><c>true</c> if the given plugins are in a valid order;
		/// <c>false</c> otherwise.</returns>
		public bool ValidateOrder(IList<Plugin> p_lstPlugins)
		{
			if (p_lstPlugins.Count < OrderedCriticalPluginNames.Length)
				return false;
			for (Int32 i = 0; i < OrderedCriticalPluginNames.Length; i++)
				if (!p_lstPlugins[i].Filename.Equals(OrderedCriticalPluginNames[i], StringComparison.OrdinalIgnoreCase))
					return false;
			bool booIsPreviousMaster = true;
			foreach (GamebryoPlugin plgPlugin in p_lstPlugins)
			{
				if (!booIsPreviousMaster && plgPlugin.IsMaster)
					return false;
				booIsPreviousMaster = plgPlugin.IsMaster;
			}
			for (Int32 i = p_lstPlugins.Count - 1; i >= 0; i--)
				if (p_lstPlugins[i].HasMasters)
					foreach (string pluginName in p_lstPlugins[i].Masters)
					{
						Int32 masterIndex = p_lstPlugins.IndexOf(p => Path.GetFileName(p.Filename).Equals(pluginName, StringComparison.OrdinalIgnoreCase));
						if (i < masterIndex)
							return false;
					}

			return true;
		}
开发者ID:etinquis,项目名称:nexusmodmanager,代码行数:31,代码来源:GamebryoPluginOrderValidator.cs


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