全て
| カテゴリ未分類
| 通常
| 数学
| 投資
| 副業
| 転職・就職
| ブログ
| 株Stock
| VBA
| SharePoint
| REST API
| RenderListDataAsStream
| PowerAutomateDesktop
| Graph API
| PowerApps
| PowerAutomate
| PowerFx
| OfficeScriptオフィススクリプト
| PowerAutomate日時Excel日時相互関係
| PowerShell
| Dataverse
| UiPath
| OneDrive
| LINQ
| VB.NET
| C#.NET
| WPFC#.NET
| Git
カテゴリ:LINQ
using System; using System.Data; using System.Linq; class Program { static void Main() { // サンプルのデータテーブルを作成する DataTable dt = new DataTable(); dt.Columns.Add("Column1", typeof(int)); dt.Columns.Add("Column2", typeof(string)); dt.Columns.Add("Column3", typeof(double)); dt.Rows.Add(3, "Row1", 10.5); dt.Rows.Add(1, "Row2", 20.5); dt.Rows.Add(2, "Row3", 30.5); // LINQを使用して列1でデータテーブルの行をソートする var sortedRows = dt.AsEnumerable() .OrderBy(row => row.Field<int>("Column1")) .CopyToDataTable(); // ソートされた行を出力する foreach (DataRow row in sortedRows.Rows) { Console.WriteLine($"Column1: {row["Column1"]}, Column2: {row["Column2"]}, Column3: {row["Column3"]}"); } } } お気に入りの記事を「いいね!」で応援しよう
Last updated
2024.02.23 14:28:50
[LINQ] カテゴリの最新記事
|