ブログに書くネタ&プログラミング面接対策として、AtCoder を始めてみた。 まずは入門である AtCoder Beginners Selection からコツコツやっていく。
b と c の代入に、あえての Deconstruct。 ただ単に Deconstruct を使ってみたかっただけ。 業務で Deconstruct 使う機会が無かったもので。
using System; using System.Collections.Generic; namespace PracticeA { class Program { static void Main(string[] args) { var a = int.Parse(Console.ReadLine()); var (b, c) = Console.ReadLine().Split(' '); var s = Console.ReadLine(); Console.WriteLine($"{a + b + c} {s}"); } } static class ListExtensions { public static void Deconstruct(this IList<string> list, out int b, out int c) { b = int.Parse(list[0]); c = int.Parse(list[1]); } } }