C#LinqSelectメソッド
Selectメソッドを使用して、配列内の要素を変更します。
以下は文字列配列です。
string[] stationery = { "diary", "board", "pencil", "whiteboard" }; Selectメソッドは、以下に示すようにラムダ式も指定します-
例
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
string[] stationery = { "diary", "board", "pencil", "whiteboard" };
var res = stationery.AsQueryable().Select((item, index) => new { result = item.Substring(0, index + 4) });
foreach (var str in res) {
Console.WriteLine("{0}", str);
}
}
} 出力
{ result = diar }
{ result = board }
{ result = pencil }
{ result = whitebo } -
HTML DOM Select remove()メソッド
HTML DOM select remove()メソッドは、HTMLドキュメントのドロップダウンリストから新しいオプションを削除します。 構文 以下は構文です- object.remove(index) ここで、indexは、ドロップダウンリストから削除されるオプションのインデックスを表します。 例 HTML DOM select remove()メソッドの例を見てみましょう- <!DOCTYPE html> <html> <head> <style> html{ heig
-
HTML DOM Textarea select()メソッド
HTML DOM Textarea select()メソッドは、HTMLドキュメントのテキスト領域のコンテンツを選択します。 構文 以下は構文です- object.select() HTML DOM Textarea select()メソッドの例を見てみましょう- 例 <!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; } &n