- ふらっと C#,C♯,C#(初心者用) Part118 [転載禁止]©2ch.net
108 :デフォルトの名無しさん[sage]:2015/12/04(金) 18:33:00.85 ID:fudonlIp - これでどう?
public class Serihu { private readonly Func<string> factory; public Serihu(Func<string> text) { factory = text; } public Serihu(string text) : this(() => text) {} public Serihu(string pre, Func<string> text, string post) : this(() => pre + text() + post) {} public override string ToString() { return factory(); } } var serihu = new[] { new Serihu("こんにちは"), new Serihu("僕は", GetItemumei, "を使った"), new Serihu(() => $"僕は{itemmei}を使った") };
|
|