C# ラムダ演算子で文字列を1文字ずつに分解する

C#で、ラムダ演算子を使用して、文字列を1文字ずつに分解するサンプルコードを記述してます。
環境
- OS windows10 pro 64bit
- Microsoft Visual Studio Community 2019 Version 16.7.1
1文字ずつに分解
ラムダ演算子を使用して、文字列「mebee」を1文字に分解して各文字の間に
「 スペース」を入れます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
using System; using System.Collections.Generic; using System.Linq; namespace testapp { class Program { static void Main(string[] args) { string str = "mebee"; Console.WriteLine(String.Join(" ", str.Select(x => x))); // m e b e e Console.ReadKey(); } } } |
-
前の記事
javascript afterで直後のノードにテキストや要素を追加する 2021.01.15
-
次の記事
背景にガラス板のような美しいエフェクトを与えるCSSの新しいプロパティ「backdrop-filter」 2021.01.16
コメントを書く