ソースコード using System; using System.Collections.Generic; using System.Linq; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // 逆</int,>…
ソースコード System.Random 版 using System; using System.Collections.Generic; using System.Linq; public static partial class IEnumerableExt { private static readonly Random m_random = new Random(); public static T RandomAt<T>( this IEnumerable<T></t></t>…
ソースコード using System; using System.Collections.Generic; using System.Linq; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // Fi</int,>…
ソースコード using System; using System.Collections; using System.Collections.Specialized; public static class Program { private static void Main() { // OrderedDictionary を使用すると登録順を取得できます var table = new OrderedDictionary {…
方法1 - SortedDictionary を使用する using System; using System.Collections.Generic; public static class Program { private static void Main() { var table = new SortedDictionary<int, string> { { 3, "フシギバナ" }, { 2, "フシギソウ" }, { 1, "フシギダネ" }</int,>…
方法 FirstOrDefault 関数を使用 using System; using System.Collections.Generic; using System.Linq; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシ</int,>…
ソースコード using System; using System.Collections.Generic; public static class Program { private static void Main() { // デフォルトでは大文字と小文字は区別される var table1 = new Dictionary<string, int>(); table1.Add( "sample", 1 ); table1.Add( "Samp</string,>…
ソースコード using System; using System.Collections.Generic; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // キーと値を同時に参照</int,>…
ソースコード using System.Collections.Generic; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // 指定されたキーの要素を削除する tabl</int,>…
メンバ変数の場合 using System.Collections.Generic; public class Program { // コレクション初期化子を使用する方法 その1 public Dictionary<int, string> m_table1 = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // コレク</int,></int,>…
ソースコード using System.Collections.Generic; using System.Linq; public static class Program { private static void Main() { var table = new Dictionary<int, string> { { 1, "フシギダネ" }, { 2, "フシギソウ" }, { 3, "フシギバナ" }, }; // キーの配列に変換</int,>…
スライド
はじめに 「LinqFaster」をプロジェクトに追加することで 高速な LINQ を使用できるようになります インストール Visual Studio メニューの「ツール>NuGet パッケージ マネージャー> ソリューションの NuGet パッケージの管理」を選択します 「参照」タブを…
ソースコード using System.Collections.Generic; public static class KeyValuePairExt { public static void Deconstruct<TKey, TValue> ( this KeyValuePair<TKey, TValue> self, out TKey key, out TValue value ) { key = self.Key; value = self.Value; } } 使用例 通常 foreach ( </tkey,></tkey,>…
ソースコード using System; public static class DateTimeExt { public static void Deconstruct ( this DateTime self, out int year, out int month, out int day ) { year = self.Year; month = self.Month; day = self.Day; } } 使用例 通常 var dt = D…
ソースコード public static class NullableExt { public static void Deconstruct<T> ( this T? self, out bool hasValue, out T value ) where T : struct { hasValue = self.HasValue; value = self ?? default; } } 使用例 var now = DateTime.Now; var ( h</t>…
概要 using System; using System.Diagnostics; using System.IO; class Program { static void Main() { var path = "【対象のフォルダ】"; var pattern = "【検索パターン】"; var option = SearchOption.AllDirectories; var sw1 = new Stopwatch(); sw1.…
ソースコード public static class StringExt { public static bool IsLower( this string self ) { for ( int i = 0; i < self.Length; i++ ) { if ( char.IsUpper( self[ i ] ) ) { return false; } } return true; } } 使い方 var str = "abcde"; var isL…
ソースコード public static class StringExt { public static bool IsUpper( this string self ) { for ( int i = 0; i < self.Length; i++ ) { if ( char.IsLower( self[ i ] ) ) { return false; } } return true; } } 使い方 var str = "ABCDE"; var isU…
23:00# スライド
スライド
スライド
スライド 参考サイト様
ソースコード using System; using System.Linq; public static class StringExt { public static string GetFirstLine( this string self ) { var separator = new [] { Environment.NewLine }; return self .Split( separator, StringSplitOptions.None ) …
ソースコード using System.Collections.Generic; using System.Text; public static class StringExt { /// <summary> /// 指定されたバイト数で文字列を分割して返します /// </summary> public static IList<string> SplitByMultiByte( this string self, int count ) { var result =</string>…
はじめに 「dotPeek」を使用すると .NET アセンブリを逆コンパイルできるようになります 入手方法 上記のページで「GET DOTPEEK」を選択することで入手できます 使い方 .dll ファイルをドラッグ&ドロップすることで、その .dll を逆コンパイルできます
ソースコード public static class FileUtils { public static string ToReadableSize( double size, int scale = 0, int standard = 1024 ) { var unit = new[] { "B", "KB", "MB", "GB" }; if ( scale == unit.Length - 1 || size <= standard ) { return …
概要 System.IO.FileNotFoundException: ファイルまたはアセンブリ 'System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'、 またはその 依存関係の 1 つが読み込めませんでした。 指定されたファイルが…
概要 the current .NET SDK does not support targeting .NET Core XXXX Visual Studio でソリューションをビルドしようとしたところ、上記のエラーが発生した https://dotnet.microsoft.com/download/visual-studio-sdks 上記のサイトから該当する SDK をイ…
ソースコード 使い方 var path = @"syukujitsu_kyujitsu.csv"; var now = DateTime.Now; LastBusinessDayOfWeekChecker.Load( path ); var isLast = LastBusinessDayOfWeekChecker.IsLast( now ); 補足 CsvHelper を使用しています(https://joshclose.githu…