概要 private (int id, string name) GetCharacter() { return ( 25, "ピカチュウ" ); } 関数の戻り値で ValueTuple を使用することで var character = GetCharacter(); Console.WriteLine( character.id + ", " + character.name ); var ( id, name ) = Get…
ソースコード using System.Collections.Generic; using System.Linq; public static class IEnumerableExt { public static IEnumerable<(T item1, T item2)> Combine<T> ( this IEnumerable<T> first, IEnumerable<T> second ) { return first.SelectMany( i1 => se</t></t></t>…
概要 using System.Linq; using UnityEngine; public class Example : MonoBehaviour { private static string[] m_list = { "フシギダネ", "フシギソウ", "フシギバナ", }; private void Update() { // 匿名型 var r1 = m_list.Select( c => new { name = c…
ソースコード using System; using System.Collections.Generic; public static class IEnumerableExt { public static IEnumerable<(int index, T value)> WithIndex<T> ( this IEnumerable<T> source ) { if ( source == null ) { throw new ArgumentNullExcepti</t></t>…
構造体を使用する方法 using System; using System.Collections.Generic; public static class Program { // 構造体でキー用のデータを定義 public struct KeyData { public int m_series; public int m_number; public KeyData( int series, int number ) {…