本文整理汇总了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;
}
}
示例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;
}
示例3: runMe
public void runMe(String input)
{
if (input.Length > 0)
{
Console.Write(input.ElementAt(input.Length - 1));
runMe(input.Remove(input.Length - 1));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}