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


C# IReadOnlyCollection.ElementAt方法代码示例

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


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

示例1: selectMember

 public void selectMember(IReadOnlyCollection<Member> list)
 {
     int choice = int.Parse(c.GetUserInput());
     if (choice == 0)
     {
         return;
     }
     choice--;
     Member member = list.ElementAt(choice);
     c.showMember(member);
     int menuChoice = int.Parse(c.GetUserInput());
     switch (menuChoice)
     {
         case 1://remove member
             mDAL.removeMemberFromList(choice);
             break;
         case 2://change first name
             member.FirstName = c.GetUserInput();
             break;
         case 3://change last name
             member.LastName = c.GetUserInput();
             break;
         case 4://change ssn
             member.SSN = c.GetUserInput();
             break;
         case 5://add a boat
             c.showBoatTypes();
             int typeChoice = int.Parse(c.GetUserInput());
             c.boatLengthPrompt();
             double lengthInput = double.Parse(c.GetUserInput());
             b = new Boat(typeChoice-1, lengthInput);
             member.AddBoat(b);
             break;
         case 6://view boats
             c.chooseBoatPrompt();
             c.showMemberBoats(member);
             updateBoat(member);
             break;
         default:
             break;
     }
 }
开发者ID:jt222ii,项目名称:1dv607workshop2,代码行数:42,代码来源:User.cs

示例2: CheckForNewChat

        private void CheckForNewChat(IReadOnlyCollection<IWebElement> elemChatWindows)
        {
            for (int i = 0; i < elemChatWindows.Count; i++) {
                string sID = GetProfileLink(elemChatWindows.ElementAt(i));

                if (sID == null) {
                    continue;
                }
                if (!windows.ContainsKey(sID)) {
                    CWindow window = new CWindow(this, replier.Whitelist, elemChatWindows.ElementAt(i));
                    window.SetReplyMode(new CInherit());
                    window.ChatMsgReceived += window_ChatMsgReceived;

                    CDebug.Print("Added a new chat: " + window.ChatName, ConsoleColor.Green);
                    windows.Add(sID, window);
                    if (ChatAdded != null) {
                        ChatAdded(window);
                    }
                    this.replier.ChatAdded_(window);
                }
            }
        }
开发者ID:Ald0s,项目名称:facebook-autoreplier,代码行数:22,代码来源:CChatMaster.cs

示例3: CheckForClosedChat

        private void CheckForClosedChat(IReadOnlyCollection<IWebElement> elemChatWindows)
        {
            List<string> exist = windows.Keys.ToList();

            for (int i = 0; i < elemChatWindows.Count; i++) {
                string sID = GetProfileLink(elemChatWindows.ElementAt(i));
                if (exist.Contains(sID)) {
                    exist.Remove(sID);
                }
            }

            for (int i = 0; i < exist.Count; i++) {
                CWindow target = windows[exist[i]];
                CDebug.Print("Removed a chat: " + target.ChatName, ConsoleColor.Red);

                target.Stop();
                if (ChatRemoved != null) {
                    ChatRemoved(target);
                }
                this.replier.ChatRemoved_(target);
                windows.Remove(exist[i]);
            }
        }
开发者ID:Ald0s,项目名称:facebook-autoreplier,代码行数:23,代码来源:CChatMaster.cs

示例4: SmoothPath

 private List<Node> SmoothPath(IReadOnlyCollection<Node> path)
 {
     var currentNode = path.Last();
     var smoothPath = new List<Node> {currentNode};
     for (var i = path.Count - 2; i >= 0; i--)
     {
         if (!IsValidNode(path.ElementAt(i), currentNode))
         {
             smoothPath.Add(path.ElementAt(i + 1));
             currentNode = path.ElementAt(i + 1);
         }
     }
     smoothPath.Add(path.First());
     return smoothPath;
 }
开发者ID:HassanNiazi,项目名称:SSL_HUB,代码行数:15,代码来源:Rrt.cs

示例5: SetAgents

 public void SetAgents(IReadOnlyCollection<TestAgent> agents)
 {
     var tests = Plan.Cases.Actives().ToList();
     int pageSize = (int)Math.Ceiling((double)tests.Count / agents.Count);
     int pageCount = (int)Math.Ceiling((double)tests.Count / pageSize);
     for (int i = 0; i < pageCount; i++)
     {
         Queues.Add(new TestQueue
         {
             Agent = agents.ElementAt(i),
             Runs = new HashSet<TestRun>(tests.Skip(i * pageSize).Take(pageSize).Select(z => new TestRun { Case = z }))
         });
     }
 }
开发者ID:moonavw,项目名称:testlab,代码行数:14,代码来源:TestSession.cs

示例6: selectMember

        // argument Listan
        public void selectMember(IReadOnlyCollection<Member> list)
        {
            ConsoleView test = new ConsoleView();
                         // show menyn

            int choice = int.Parse(Console.ReadLine());
            if(choice == 0)
            {
                return;
            }
            choice--;
            Member member = list.ElementAt(choice);
            test.ShowMembers(member);                        // skickar till show member visning av medlemmar
               int menuChoicce = int.Parse(Console.ReadLine());

                switch (menuChoicce)                    // menualternativ för Medlemmen
                {
                    case 0:
                        return;

                    case 1:
                       member.GetName = test.Rename();        // change name
                        break;

                    case 2:

                        MemberDAL.removeMember(choice);           // tas bort medlemmen
                        break;

                    case 3:
                        member.GetSecurityNumber = test.ChangeNumber();   // ändra personlighets nummer
                        break;

                    case 4:
                        test.ViewBoattype();
                        int Boatchoice = int.Parse(test.Boattypeinfo());            // användning av inmatning av boatchoice

                        double BoatLength = double.Parse(test.BoattypeLength());      //inmatning båtlängd // kan inte använda console write line eftersom det är void
                        Boat FullBoat = new Boat(Boatchoice,BoatLength);      // instans av ny objekt( med intagen längd av båtlängd och båtkategorier
                        member.sendToBoatList(FullBoat);
                        break;
                    case 5:
                        test.ShowBoat(member);
                        selectBoat(member);
                          break;

                    default: break;

                }
        }
开发者ID:jt222ic,项目名称:1dv607-jt222ic-Portfolio,代码行数:51,代码来源:User.cs

示例7: CountMinSketch

        private static Dictionary<string, int> CountMinSketch(IReadOnlyCollection<string> listOfM, int k, int t)
        {
            var counterMatrix = new Matrix(t, k);
            //map it out first
            var mMap = new Dictionary<string, int>();
            var distinctM = listOfM.Distinct().ToList();
            for (var i = 0; i < distinctM.Count; i++)
            {
                mMap[distinctM[i]] = i;
            }

            var hashFunctions = HashUtil.HashFunctions(t, k, mMap.Keys.Count).ToList();

            for (var i = 0; i < listOfM.Count; i++)
            {
                var mapResult = mMap[listOfM.ElementAt(i)];

                for (var j = 0; j < t; j++)
                {
                    var hashFunctionResult = hashFunctions[j][mapResult];
                    counterMatrix.SetValue(hashFunctionResult, j,
                        counterMatrix.GetValue(hashFunctionResult, j) + 1
                        );
                }
            }

            var resultDictionary = new Dictionary<string, int>();

            foreach(var kvp in mMap)
            {
                var minResult = int.MaxValue;
                for (var i = 0; i < t; i++)
                {
                    var hashMap = hashFunctions[i][kvp.Value];
                    var tempResult = counterMatrix.GetValue(hashMap, i);
                    if (tempResult < minResult)
                    {
                        minResult = tempResult;
                    }
                }
                resultDictionary[kvp.Key] = minResult;
            }
            return resultDictionary;
        }
开发者ID:roylanceMichael,项目名称:cs_6955_datamining_utah,代码行数:44,代码来源:Hw4.cs

示例8: VerifyDiagnosticResults

        /// <summary>
        /// Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results.
        /// Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic.
        /// </summary>
        /// <param name="actualResults">The Diagnostics found by the compiler after running the analyzer on the source code</param>
        /// <param name="analyzer">The analyzer that was being run on the sources</param>
        /// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
        private static void VerifyDiagnosticResults(IReadOnlyCollection<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
        {
            var expectedCount = expectedResults.Length;
            var actualCount = actualResults.Count;

            if (expectedCount != actualCount)
            {
                var diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzer, actualResults.ToArray()) : "    NONE.";

                Assert.IsTrue(false, $"Mismatch between number of diagnostics returned, expected \"{expectedCount}\" actual \"{actualCount}\"\r\n\r\nDiagnostics:\r\n{diagnosticsOutput}\r\n");
            }

            for (var i = 0; i < expectedResults.Length; i++)
            {
                var actual = actualResults.ElementAt(i);
                var expected = expectedResults[i];

                if (expected.Line == -1 && expected.Column == -1)
                {
                    if (actual.Location != Location.None)
                    {
                        Assert.IsTrue(false, $"Expected:\nA project diagnostic with No location\nActual:\n{FormatDiagnostics(analyzer, actual)}");
                    }
                }
                else
                {
                    VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First());
                    var additionalLocations = actual.AdditionalLocations.ToArray();

                    if (additionalLocations.Length != expected.Locations.Length - 1)
                    {
                        Assert.IsTrue(false, $"Expected {expected.Locations.Length - 1} additional locations but got {additionalLocations.Length} for Diagnostic:\r\n    {FormatDiagnostics(analyzer, actual)}\r\n");
                    }

                    for (var j = 0; j < additionalLocations.Length; ++j)
                    {
                        VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]);
                    }
                }

                if (actual.Id != expected.Id)
                {
                    Assert.IsTrue(false, $"Expected diagnostic id to be \"{expected.Id}\" was \"{actual.Id}\"\r\n\r\nDiagnostic:\r\n    {FormatDiagnostics(analyzer, actual)}\r\n");
                }

                if (actual.Severity != expected.Severity)
                {
                    Assert.IsTrue(false, $"Expected diagnostic severity to be \"{expected.Severity}\" was \"{actual.Severity}\"\r\n\r\nDiagnostic:\r\n    {FormatDiagnostics(analyzer, actual)}\r\n");
                }

                if (actual.GetMessage() != expected.Message)
                {
                    Assert.IsTrue(false, $"Expected diagnostic message to be \"{expected.Message}\" was \"{actual.GetMessage()}\"\r\n\r\nDiagnostic:\r\n    {FormatDiagnostics(analyzer, actual)}\r\n");
                }
            }
        }
开发者ID:ycherkes,项目名称:MockIt,代码行数:63,代码来源:DiagnosticVerifier.cs


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