Skip to content

Instantly share code, notes, and snippets.

@sapphire-al2o3
Created June 28, 2022 02:05
Show Gist options
  • Save sapphire-al2o3/8b29bd8b69e4ba67cee98125cb5f68fb to your computer and use it in GitHub Desktop.
Save sapphire-al2o3/8b29bd8b69e4ba67cee98125cb5f68fb to your computer and use it in GitHub Desktop.
C#でnull文字入りの文字配列を文字列にする
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