Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このコードに問題があります
string.Join(",", Encoding.Unicode.GetBytes("10.10.10.11").Select(x => x.ToString("X2")));
エラーが発生しました
cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'string[]'
また、カンマ区切りのtxtボックスにエクスポートするにはどうすればよいですか?
ToArray()拡張メソッドを呼び出すことにより、IEnumerableを文字列の配列に変換できます。
string.Join(",", Encoding.Unicode.GetBytes("10.10.10.11").Select(x => x.ToString("X2")).ToArray());
サイドノート:
.NET 4.0以降、を受け入れるオーバーロードがあり、廃止された呼び出しを行います。String.JoinIEnumerable<String>ToArray
String.Join
IEnumerable<String>
ToArray
このToArray()で試すことができます
string.Join(",", Encoding.Unicode.GetBytes("10.10.10.11") .Select(x => x.ToString("X2"))) .ToArray();