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


C# String.ElementAt方法代码示例

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


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

示例1: AllPermutations

 // Returns all permutation of 'str'
 public static List<string> AllPermutations(List<string> list, String start, String str)
 {
     if (str.Length <= 1)
         list.Add(start + str);
     else
         for (int i = 0; i < str.Length; i++)
         {
             String newStr = str.Substring(0, i) + str.Substring(i + 1);
             AllPermutations(list, start + str.ElementAt(i), newStr);
         }
     return list;
 }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:13,代码来源:Permutations.cs

示例2: handleChatInput

    protected void handleChatInput(String line)
    {
        if (line.Length > 0)
        {
            if (quitHelperMessageShow && (line == "q" || line == "Q"))
            {
                Console.WriteLine();
                enqueuePluginChatMessage("If you are trying to quit, use the /quit command.", true);
                quitHelperMessageShow = false;
            }

            if (line.ElementAt(0) == '/')
            {
                String line_lower = line.ToLower();

                if (line_lower == "/quit")
                {
                    intentionalConnectionEnd = true;
                    endSession = true;
                    sendConnectionEndMessage("Quit");
                }
                else if (line_lower == "/crash")
                {
                    Object o = null;
                    o.ToString();
                }
                else if (line_lower == "/ping")
                {
                    if (!pingStopwatch.IsRunning)
                    {
                        sendMessageTCP(KLFCommon.ClientMessageID.PING, null);
                        pingStopwatch.Start();
                    }
                }
                else if (line_lower.Length > (KLFCommon.SHARE_CRAFT_COMMAND.Length + 1)
                    && line_lower.Substring(0, KLFCommon.SHARE_CRAFT_COMMAND.Length) == KLFCommon.SHARE_CRAFT_COMMAND)
                {
                    //Share a craft file
                    String craft_name = line.Substring(KLFCommon.SHARE_CRAFT_COMMAND.Length + 1);
                    byte craft_type = 0;
                    String filename = findCraftFilename(craft_name, ref craft_type);

                    if (filename != null && filename.Length > 0)
                    {
                        try
                        {
                            byte[] craft_bytes = File.ReadAllBytes(filename);
                            sendShareCraftMessage(craft_name, craft_bytes, craft_type);
                        }
                        catch
                        {
                            enqueueTextMessage("Error reading craft file: " + filename);
                        }
                    }
                    else
                        enqueueTextMessage("Craft file not found: " + craft_name);
                }

            }
            else
            {
                sendTextMessage(line);
            }
        }
    }
开发者ID:Will565,项目名称:IFI-Kerbal-Live-Feed,代码行数:65,代码来源:Client.cs

示例3: HandleChatInput

 protected void HandleChatInput(String line)
 {
     if(line.Length > 0 && line.ElementAt(0) == '/')
     {
         String[] InputArgs = line.Split(' ');
         switch(InputArgs[0].ToLowerInvariant())
         {
             case "/quit":
                 IntentionalConnectionEnd = true;
                 EndSession = true;
                 SendConnectionEndMessage("Quit");
                 break;
             case "/crash":
                 Object o = null;
                 o.ToString();
                 break;
             case "/ping":
                 if (!PingStopwatch.IsRunning)
                 {
                     SendMessageTcp(KLFCommon.ClientMessageID.Ping, null);
                     PingStopwatch.Start();
                 }
                 break;
             case KLFCommon.ShareCraftCommand:
                 if(InputArgs.Length > 1)
                 {
                     String craftName = String.Join(" ", InputArgs, 1, InputArgs.Length - 2);
                     byte craftType = 0;
                     String filename = FindCraftFilename(craftName, ref craftType);
                     if (filename != null && filename.Length > 0)
                     {
                         try
                         {
                             byte[] craftBytes = File.ReadAllBytes(filename);
                             SendShareCraftMessage(craftName, craftBytes, craftType);
                         }
                         catch
                         {
                             EnqueueTextMessage("Error reading craft file: " + filename);
                         }
                     }
                     else
                         EnqueueTextMessage("Craft file not found: " + craftName);
                 }
                 break;
             default:
                 EnqueueTextMessage("Unrecognized command: " + InputArgs[0]);
                 break;
         }
     }
     else
         SendTextMessage(line);
 }
开发者ID:velusip,项目名称:KerbalLiveFeed,代码行数:53,代码来源:Client.cs


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