Convert a word into character array

后端 未结 5 1708
花落未央
花落未央 2021-01-19 07:16

How do I convert a word into a character array?

Lets say i have the word \"Pneumonoultramicroscopicsilicovolcanoconiosis\" yes this is a word ! I would like to take

5条回答
  •  余生分开走
    2021-01-19 07:58

    what about

    char[] myArray = myString.ToCharArray();
    

    But you don't actually need to do this if you want to iterate the string. You can simply do

    for( int i = 0; i < myString.Length; i++ ){
      if( myString[i] ... ){
        //do what you want here
      }
    }
    

    This works since the string class implements it's own indexer.

提交回复
热议问题