CODEKILLER

반응형

char array
char array

public class Example
{
    public static void Main()
    {
        string txt = "I am stronger than Batman.";
        Console.WriteLine(txt);

        char[] phraseAsChars = txt.ToCharArray();
        int searchIndex = txt.IndexOf("Batman");
        if (searchIndex != -1)
        {
            phraseAsChars[searchIndex++] = 'C';
            phraseAsChars[searchIndex++] = 'a';
            phraseAsChars[searchIndex++] = 't';
            phraseAsChars[searchIndex++] = 'm';
            phraseAsChars[searchIndex++] = 'a';
            phraseAsChars[searchIndex++] = 'n';
        }

        string updatedPhrase = new string(phraseAsChars);
        Console.WriteLine(updatedPhrase);
    }
}

 

반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band