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


C# String.ElementAt方法代码示例

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


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

示例1: formatarDataHora

 public String formatarDataHora(String dataHora)
 {
     if (dataHora.ElementAt(2).Equals('/'))
     {
         String dia, mes, ano,h,min,seg;
         dia = dataHora.Substring(0, 2);
         mes = dataHora.Substring(3, 2);
         ano = dataHora.Substring(6, 4);
         h = dataHora.Substring(11,2);
         min = dataHora.Substring(14,2);
         seg = dataHora.Substring(17,2);
         String dataFormt = ano + "/" + mes + "/"+dia+" "+h+":"+min+":"+seg;
         String dataN = dataFormt;
         return dataN;
     }
     else
     {
         String dia, mes, ano, h, min, seg;
         ano = dataHora.Substring(0, 4);
         mes = dataHora.Substring(5, 2);
         dia = dataHora.Substring(8, 2);
         h = dataHora.Substring(11, 2);
         min = dataHora.Substring(14, 2);
         seg = dataHora.Substring(17, 2);
         String dataFormt = dia + "/" + mes + "/" + ano + " " + h + ":" + min + ":" + seg;
         String dataN = dataFormt;
         return dataN;
     }
 }
开发者ID:paulorcmendes,项目名称:pamonhaDeveloper,代码行数:29,代码来源:Formatador.cs

示例2: Put

        public Node Put(Node x, String key, char val, int d)
        {
            if (x == null)
                x = new Node();

            if(d == key.Length)
            {
                x.Value = val;
                return x;
            }

            var c = key.ElementAt(d);

            if (x.next[c] != null)
            {
                if (x.next[c].HasItem)
                {
                    Count++;
                }

            }
            x.next[c] = Put(x.next[c], key, val, d + 1);
            x.next[c].HasItem = true;

            return x;
        }
开发者ID:Firyuza,项目名称:Algorithms-101,代码行数:26,代码来源:TrieST.cs

示例3: runMe

 public void runMe(String input)
 {
     if (input.Length > 0)
     {
         Console.Write(input.ElementAt(input.Length - 1));
         runMe(input.Remove(input.Length - 1));
     }
 }
开发者ID:TerrorEdje,项目名称:Algoritmiek,代码行数:8,代码来源:NeiaardmoGnirts.cs

示例4: setNomInstrumentSansEspaces

        public String setNomInstrumentSansEspaces(String nom)
        {
            String nomCopie = "";

            for (int i = 0; i < nom.Length; i++)
            {
                if (nom.ElementAt(i) == ' ')
                {
                    nomCopie += '_';
                }
                else
                {
                    nomCopie += nom.ElementAt(i);
                }
            }

            return nomCopie;
        }
开发者ID:Nicejuju,项目名称:ProjetWindowsPhoneDaveMuret,代码行数:18,代码来源:ListMusicianByInstrViewModel.cs

示例5: getRelacion

 public static LinkedList<String> getRelacion(String line)
 {
     LinkedList<String> UA = new LinkedList<string>();
     int i = 2;
     while (line.Length > i)
     {
         String word = "";
         while (line.ElementAt(i) >= 'A' && line.ElementAt(i) <= 'Z' || line.ElementAt(i) >= 'a' && line.ElementAt(i) <= 'z')
         {
             word = String.Concat(word, line.ElementAt(i).ToString());
             ++i;
         }
         if (word.Length > 0)
             UA.AddLast(word);
         ++i;
     }
     return UA;
 }
开发者ID:Baptista,项目名称:SI,代码行数:18,代码来源:PEP.cs

示例6: setNomMusicienSansEspaces

        public String setNomMusicienSansEspaces(String nom)
        {
            //Il faut remplacer les espaces du nom par un caractère (ici _) pour pouvoir l'envoyer dans l'url
            String nomCopie = "";

            for (int i = 0; i < nom.Length; i++)
            {
                if (nom.ElementAt(i) == ' ')
                {
                    nomCopie += '_';
                }
                else
                {
                    nomCopie += nom.ElementAt(i);
                }
            }

            return nomCopie;
        }
开发者ID:Nicejuju,项目名称:ProjetWindowsPhoneDaveMuret,代码行数:19,代码来源:DetailsMusicianViewModel.cs

示例7: PrintVertical

 private void PrintVertical(String input)
 {
     for (int i = 0; i < input.Length; i++)
     {
         Console.CursorLeft = cursorIndex;
         Console.Write(input.ElementAt(i));
         cursorIndex = Console.CursorLeft;
         if (!(input.Length - i == 1))
         {
             cursorIndex--;
             Console.Write("\n");
         }
     }
 }
开发者ID:Eogcloud,项目名称:WordSnake,代码行数:14,代码来源:WordSnake.cs

示例8: checkCorrect

        private Boolean checkCorrect(String s)
        {
            if (s.Equals("") || s.Equals("\n")) {
                return false;
            }

            for (int i = 0; i < s.Length; i++) {
                if (!char.IsLetterOrDigit(s.ElementAt(i))) {
                    return false;
                }
            }

            return true;
        }
开发者ID:Cotel,项目名称:MultiThread-Chat,代码行数:14,代码来源:Servidor.cs

示例9: recursFunct

 public static void recursFunct(String begining,String ending)
 {
     if(ending.Length<=1)
     {
         Console.WriteLine(begining + ending);
     }
     else
     {
         for(int i=0;i<ending.Length;i++)
         {
             String newString = ending.Substring(0, i) + ending.Substring(i + 1);
             recursFunct(begining + ending.ElementAt(i), newString);
         }
     }
 }
开发者ID:HristoHristov95,项目名称:C-Soft-Intellect,代码行数:15,代码来源:Program.cs

示例10: PermuteString

        public List<string> PermuteString(String beginningString, String endingString)
        {
            List<string> result = new List<string>();
            if (endingString.Length <= 1)
                result.Add(beginningString + endingString);
            else
            {
                for (int i = 0; i < endingString.Length; i++)
                {
                    String newString = endingString.Substring(0, i) + endingString.Substring(i + 1);
                    result.AddRange(PermuteString(beginningString + endingString.ElementAt(i), newString));
                }
            }

            return result;
        }
开发者ID:Subv,项目名称:Ejercicios,代码行数:16,代码来源:Euler43.cs

示例11: Reverse

 public static String Reverse(String str)
 {
     if (str == null)
     {
         throw new ArgumentNullException("str");
     }
     if (str.Trim().Length == 0)
     {
         return str;
     }
     StringBuilder reverseString = new StringBuilder();
     for (int i = 0; i < str.Length; i++)
     {
         reverseString.Append(str.ElementAt(str.Length - 1 - i));
     }
     return reverseString.ToString();
 }
开发者ID:Kireki,项目名称:PasswordCrackerServiceConsumer,代码行数:17,代码来源:StringUtilities.cs

示例12: writeAscii

 /** Writes a string that is known to contain only ASCII characters. Non-ASCII strings passed to this method will be corrupted.
  * Each byte is a 7 bit character with the remaining byte denoting if another character is available. This is slightly more
  * efficient than {@link #writeString(String)}. The string can be read using {@link Input#readString()} or
  * {@link Input#readStringBuilder()}.
  * @param value May be null. */
 public void writeAscii(String value)
 {
     if (value == null)
     {
         writeByte(0x80); // 0 means null, bit 8 means UTF8.
         return;
     }
     int charCount = value.Length;
     switch (charCount)
     {
         case 0:
             writeByte(1 | 0x80); // 1 is string length + 1, bit 8 means UTF8.
             return;
         case 1:
             writeByte(2 | 0x80); // 2 is string length + 1, bit 8 means UTF8.
             writeByte(value.ElementAt(0));
             return;
     }
     byte[] buffer = new byte[charCount];
     Encoding.UTF8.GetBytes(value.ToCharArray(), 0, charCount, buffer, 0);
     buffer[charCount - 1] |= 0x80; // Bit 8 means end of ASCII.
     WriteBytes(buffer);
 }
开发者ID:b-cuts,项目名称:POxOSerializer,代码行数:28,代码来源:POxOPrimitiveEncoder.cs

示例13: formatarData

 public String formatarData(String data)
 {
     if (data.ElementAt(2).Equals('/'))
     {
         String dia, mes, ano;
         dia = data.Substring(0, 2);
         mes = data.Substring(3, 2);
         ano = data.Substring(6, 4);
         String dataFormt = ano + "/" + mes + "/" + dia;
         String dataN = dataFormt;
         return dataN;
     }
     else
     {
         String dia, mes, ano;
         ano = data.Substring(0, 4);
         mes = data.Substring(5, 2);
         dia = data.Substring(8, 2);
         String dataFormt = dia + "/" + mes + "/" + ano;
         String dataN = dataFormt;
         return dataN;
     }
 }
开发者ID:paulorcmendes,项目名称:pamonhaDeveloper,代码行数:23,代码来源:Formatador.cs

示例14: CloseAndOpenBracketOrEndIsFound

 private static bool CloseAndOpenBracketOrEndIsFound(String stringInput, int i)
 {
     return (stringInput.ElementAt(i).Equals(']') && i < stringInput.Length - 2 && stringInput.ElementAt(i + 1).Equals('[')) ||
         (stringInput.ElementAt(i).Equals(']') && i == stringInput.Length - 1);
 }
开发者ID:ImpulseChimp,项目名称:CodingKatas,代码行数:5,代码来源:StringCalculator.cs

示例15: GetRuVerb1

        private static String GetRuVerb1(String sourceWord)
        {
            char lastSign = sourceWord.ElementAt(sourceWord.Length - 3);

            switch (lastSign)
            {
                case 'い': lastSign = 'う'; break;
                case 'き': lastSign = 'く'; break;
                case 'し': lastSign = 'す'; break;
                case 'ち': lastSign = 'つ'; break;
                case 'に': lastSign = 'ぬ'; break;
                case 'ひ': lastSign = 'ふ'; break;
                case 'み': lastSign = 'む'; break;
                case 'り': lastSign = 'る'; break;
                case 'ぎ': lastSign = 'ぐ'; break;
                case 'じ': lastSign = 'ず'; break;
                case 'ぢ': lastSign = 'づ'; break;
                case 'び': lastSign = 'ぶ'; break;
                case 'ぴ': lastSign = 'ぷ'; break;
            }

            return sourceWord.Substring(0, sourceWord.Length - 3) + lastSign;
        }
开发者ID:deadkitty,项目名称:Mobile-Computing,代码行数:23,代码来源:ConjugationController.cs


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