using System.Text.RegularExpressions;publicclassKata{publicstaticstringVowel2Index(string str){return Regex.Replace(str,"[aeiou]", x =>(x.Index +1).ToString());}}
答案2:
using System;using System.Linq;publicclassKata{publicstaticstringVowel2Index(string str){return String.Concat(str.Select((c, i)=>"aeiouAEIOU".IndexOf(c)!=-1?""+(i +1):""+ c));}}
答案3:
using System;using System.Diagnostics.CodeAnalysis;using System.Linq;publicclassKata{publicstaticstringVowel2Index(string str){char[] vowels ={'a','e','o','i','u'};string[] strArray =newstring[str.Length];for(int i =0; i < str.Length; i++){
strArray[i]= str[i].ToString();if(vowels.Any(c => c == Convert.ToChar(strArray[i])))
strArray[i]=(i +1).ToString();}returnstring.Concat(strArray);}}
publicclassKata{publicstaticstringVowel2Index(string str){string result ="";for(int i =0; i < str.Length; i++){if( str[i]=='a'|| str[i]=='e'|| str[i]=='i'|| str[i]=='o'|| str[i]=='u')
result += i+1;else
result += str[i].ToString();}return result;}}
答案6:
using System.Text.RegularExpressions;publicclassKata{publicstaticstringVowel2Index(string str){returnnewRegex(".").Replace(str, Match =>"aeiou".IndexOf(Match.Value.ToLower())>-1?(Match.Index +1).ToString(): Match.Value);}}
答案7:
using System.Text.RegularExpressions;using System.Linq;publicclassKata{publicstaticstringVowel2Index(string str)=>string.Concat(str.Select((x,i)=>"aeiouAEIOU".IndexOf(x)<0?x.ToString():(i+1).ToString()));}
答案8:
using System;using System.Linq;using System.Text.RegularExpressions;publicclassKata{publicstaticstringVowel2Index(string str){return String.Concat(str.Select((c,i)=>"aeiouAEIOU".Contains(c)?(i+1).ToString(): c.ToString()));}}
答案9:
using System.Collections;using System.Collections.Generic;using System.Linq;publicclassKata{publicstaticstringVowel2Index(string str){var vowels =newList<char>{'a','e','i','o','u'};var i =0;returnstring.Join("", str.Select(c =>{ i++;return vowels.Contains(c)? i.ToString(): c.ToString();}));}}
答案10:
using System.Linq;publicclassKata{publicstaticstringVowel2Index(string str)=>string.Concat(str.Select((e,i)=>"aeiou".Contains(e)?(i+1).ToString(): e.ToString()));}