Created
June 28, 2022 02:05
-
-
Save sapphire-al2o3/8b29bd8b69e4ba67cee98125cb5f68fb to your computer and use it in GitHub Desktop.
C#でnull文字入りの文字配列を文字列にする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
char[] text = { 'a', 'b', '\0', 'c', 'd' }; | |
int length = 0; | |
for (int i = 0; i < text.Length; i++) | |
{ | |
if (text[i] == '\0') | |
{ | |
length = i; | |
break; | |
} | |
} | |
string str = new string(text, 0, length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment