{"id":1632,"date":"2024-12-12T13:50:36","date_gmt":"2024-12-12T04:50:36","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=1632"},"modified":"2025-03-24T08:50:13","modified_gmt":"2025-03-23T23:50:13","slug":"c-arraylist%e3%81%ae%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%9f%ba%e7%a4%8e%e3%81%8b%e3%82%89%e6%9c%80%e6%96%b0%e3%81%ae%e4%bb%a3%e6%9b%bf%e6%89%8b%e6%ae%b5%e3%81%be%e3%81%a7","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=1632","title":{"rendered":"C# ArrayList\u306e\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u57fa\u790e\u304b\u3089\u6700\u65b0\u306e\u4ee3\u66ff\u624b\u6bb5\u307e\u3067\u89e3\u8aac"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">\u306f\u3058\u3081\u306b<\/a>  <\/li>  <li>    <a href=\"#i-1\">ArrayList\u3068\u306f\uff1aC#\u3067\u306e\u5f79\u5272\u3068\u57fa\u672c\u6982\u5ff5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-2\">ArrayList\u306e\u5b9a\u7fa9\u3068\u4e3b\u306a\u7279\u5fb4\u3092\u7406\u89e3\u3059\u308b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-4\">ArrayList\u304c\u751f\u307e\u308c\u305f\u80cc\u666f\u3068\u305d\u306e\u6b74\u53f2<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-5\">ArrayList\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u30de\u30b9\u30bf\u30fc\u30ac\u30a4\u30c9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-6\">ArrayList\u306e\u521d\u671f\u5316\u3068\u8981\u7d20\u306e\u8ffd\u52a0\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u8981\u7d20\u306e\u53d6\u5f97\u3068\u578b\u30ad\u30e3\u30b9\u30c8\u306e\u6ce8\u610f\u70b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">\u8981\u7d20\u306e\u524a\u9664\u3068\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u64cd\u4f5c\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">ArrayList\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u7279\u6027\u3092\u5fb9\u5e95\u89e3\u8aac<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3068\u52d5\u7684\u306a\u914d\u5217\u62e1\u5f35\u306e\u4ed5\u7d44\u307f<\/a>      <\/li>      <li>        <a href=\"#i-11\">\u578b\u5b89\u5168\u6027\u306b\u304a\u3051\u308b\u5236\u7d04\u3068\u5b9f\u884c\u6642\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-12\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u51e6\u7406\u6642\u306e\u6ce8\u610f\u70b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-13\">\u73fe\u4ee3\u306eC#\u958b\u767a\uff1aArrayList\u304b\u3089\u6700\u65b0\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3078\u306e\u79fb\u884c<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-14\">List&lt;T&gt;\u306b\u3088\u308b\u578b\u5b89\u5168\u6027\u306e\u78ba\u4fdd\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/a>      <\/li>      <li>        <a href=\"#i-15\">\u30ec\u30ac\u30b7\u30fc\u30b3\u30fc\u30c9\u306e\u5b89\u5168\u306a\u79fb\u884c\u624b\u9806<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-16\">\u79fb\u884c\u5f8c\u306e\u30b3\u30fc\u30c9\u54c1\u8cea\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u5411\u4e0a<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-17\">ArrayList\u306e\u6d3b\u7528\u30b7\u30fc\u30f3\u3068\u4ee3\u66ff\u624b\u6bb5\u306e\u9078\u629e\u57fa\u6e96<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-18\">ArrayList\u304c\u4f9d\u7136\u3068\u3057\u3066\u6709\u52b9\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/a>      <\/li>      <li>        <a href=\"#i-20\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u305f\u6700\u9069\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-21\">\u5c06\u6765\u3092\u898b\u636e\u3048\u305f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u8a2d\u8a08\u306e\u8003\u3048\u65b9<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-22\">ArrayList\u306e\u307e\u3068\u3081<\/a>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>C#\u306eArrayList\u306f.NET Framework 1.0\u304b\u3089\u5b58\u5728\u3059\u308b\u6c4e\u7528\u7684\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3067\u3059\u3002\u578b\u3092\u554f\u308f\u305a\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3067\u304d\u308b\u67d4\u8edf\u6027\u3092\u6301\u3061\u307e\u3059\u304c\u3001\u73fe\u4ee3\u306eC#\u958b\u767a\u3067\u306f\u3088\u308a\u578b\u5b89\u5168\u306a\u4ee3\u66ff\u624b\u6bb5\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u672c\u8a18\u4e8b\u3067\u306f\u3001ArrayList\u306e\u57fa\u790e\u304b\u3089\u5b9f\u8df5\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u3001\u305d\u3057\u3066\u73fe\u4ee3\u306e\u958b\u767a\u306b\u304a\u3051\u308b\u9069\u5207\u306a\u9078\u629e\u57fa\u6e96\u307e\u3067\u3001\u5305\u62ec\u7684\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u672c\u8a18\u4e8b\u3067\u5b66\u3079\u308b\u3053\u3068<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<p class=\"is-style-sango-paragraph-idea-alt\">ArrayList\u306e\u57fa\u672c\u7684\u306a\u4ed5\u7d44\u307f\u3068\u7279\u5fb4\u7684\u306a\u6a5f\u80fd<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u5b9f\u7528\u7684\u306a\u30b3\u30fc\u30c9\u4f8b\u3092\u901a\u3058\u305f\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u9069\u5207\u306a\u4f7f\u7528\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u73fe\u4ee3\u306eC#\u958b\u767a\u306b\u304a\u3051\u308b\u4ee3\u66ff\u624b\u6bb5\uff08List&lt;T&gt;\u7b49\uff09\u3078\u306e\u79fb\u884c\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30ec\u30ac\u30b7\u30fc\u30b3\u30fc\u30c9\u306e\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u306b\u5fc5\u8981\u306a\u77e5\u8b58<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u9069\u3057\u305f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e\u306e\u5224\u65ad\u57fa\u6e96<\/p>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5185\u5bb9\u3092\u901a\u3058\u3066\u3001ArrayList\u306e\u5b9f\u8df5\u7684\u306a\u6d3b\u7528\u65b9\u6cd5\u304b\u3089\u3001\u73fe\u4ee3\u306eC#\u958b\u767a\u306b\u304a\u3051\u308b\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u307e\u3067\u3092\u30de\u30b9\u30bf\u30fc\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-1\">ArrayList\u3068\u306f\uff1aC#\u3067\u306e\u5f79\u5272\u3068\u57fa\u672c\u6982\u5ff5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">ArrayList\u306e\u5b9a\u7fa9\u3068\u4e3b\u306a\u7279\u5fb4\u3092\u7406\u89e3\u3059\u308b<\/h3>\n\n\n\n<p>ArrayList\u306f\u3001C#\u306b\u304a\u3044\u3066\u53ef\u5909\u30b5\u30a4\u30ba\u306e\u914d\u5217\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3067\u3059\u3002<br>System.Collections\u540d\u524d\u7a7a\u9593\u306b\u542b\u307e\u308c\u308b\u3053\u306e\u30af\u30e9\u30b9\u306f\u3001\u4ee5\u4e0b\u306e\u4e3b\u8981\u306a\u7279\u5fb4\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-box sng-box box6\">\n<ol class=\"wp-block-list is-style-sango-list-simple\">\n<li><strong>\u52d5\u7684\u306a\u30b5\u30a4\u30ba\u8abf\u6574<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>\u8981\u7d20\u306e\u8ffd\u52a0\u30fb\u524a\u9664\u306b\u5fdc\u3058\u3066\u81ea\u52d5\u7684\u306b\u30b5\u30a4\u30ba\u304c\u5909\u66f4\u3055\u308c\u308b<\/li>\n\n\n\n<li>\u521d\u671f\u5bb9\u91cf\u3092\u6307\u5b9a\u53ef\u80fd\u3067\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u81ea\u52d5\u62e1\u5f35<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u591a\u69d8\u306a\u30c7\u30fc\u30bf\u578b\u306e\u683c\u7d0d<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>object\u578b\u3068\u3057\u3066\u8981\u7d20\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u3001\u7570\u306a\u308b\u578b\u306e\u30c7\u30fc\u30bf\u30921\u3064\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u7ba1\u7406\u53ef\u80fd<\/li>\n\n\n\n<li>\u578b\u5b89\u5168\u6027\u3088\u308a\u3082\u67d4\u8edf\u6027\u3092\u91cd\u8996\u3057\u305f\u8a2d\u8a08<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u8c4a\u5bcc\u306a\u64cd\u4f5c\u30e1\u30bd\u30c3\u30c9<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>Add(), Remove(), Insert()\u306a\u3069\u306e\u57fa\u672c\u7684\u306a\u64cd\u4f5c\u30e1\u30bd\u30c3\u30c9\u3092\u63d0\u4f9b<\/li>\n\n\n\n<li>Sort(), Reverse()\u306a\u3069\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5168\u4f53\u3092\u64cd\u4f5c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3082\u5b9f\u88c5<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-3\">\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ ArrayList\u306e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b\nusing System;\nusing System.Collections;\n\npublic class ArrayListExample\n{\n    public static void Main()\n    {\n        \/\/ ArrayList\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\n        ArrayList list = new ArrayList();\n\n        \/\/ \u69d8\u3005\u306a\u578b\u306e\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\n        list.Add(100);              \/\/ \u6574\u6570\n        list.Add(\"Hello\");          \/\/ \u6587\u5b57\u5217\n        list.Add(3.14);             \/\/ \u5c0f\u6570\n        list.Add(new DateTime());   \/\/ \u65e5\u4ed8\u578b\n\n        \/\/ \u8981\u7d20\u6570\u3068Capacity\u306e\u78ba\u8a8d\n        Console.WriteLine($\"Count: {list.Count}\");         \/\/ \u5b9f\u969b\u306e\u8981\u7d20\u6570\n        Console.WriteLine($\"Capacity: {list.Capacity}\");   \/\/ \u5185\u90e8\u914d\u5217\u306e\u30b5\u30a4\u30ba\n\n        \/\/ \u8981\u7d20\u3078\u306e\u30a2\u30af\u30bb\u30b9\uff08\u578b\u30ad\u30e3\u30b9\u30c8\u304c\u5fc5\u8981\uff09\n        int number = (int)list[0];\n        string text = (string)list[1];\n\n        \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u64cd\u4f5c\n        list.Remove(\"Hello\");     \/\/ \u7279\u5b9a\u306e\u8981\u7d20\u3092\u524a\u9664\n        list.Insert(1, \"World\");  \/\/ \u6307\u5b9a\u4f4d\u7f6e\u306b\u8981\u7d20\u3092\u633f\u5165\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">ArrayList\u304c\u751f\u307e\u308c\u305f\u80cc\u666f\u3068\u305d\u306e\u6b74\u53f2<\/h3>\n\n\n\n<p>ArrayList\u306f\u3001.NET Framework 1.0\u304b\u3089\u5b58\u5728\u3059\u308b\u6700\u3082\u53e4\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u306e1\u3064\u3067\u3059\u3002<br>\u305d\u306e\u8a95\u751f\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u80cc\u666f\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-box sng-box box6\">\n<ol class=\"wp-block-list is-style-sango-list-simple\">\n<li><strong>\u53ef\u5909\u9577\u914d\u5217\u306e\u30cb\u30fc\u30ba<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>\u56fa\u5b9a\u9577\u306e\u914d\u5217\u3067\u306f\u3001\u30b5\u30a4\u30ba\u306e\u4e8b\u524d\u6c7a\u5b9a\u304c\u5fc5\u8981<\/li>\n\n\n\n<li>\u5b9f\u884c\u6642\u306e\u30e1\u30e2\u30ea\u52b9\u7387\u5316\u3068\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5bb9\u6613\u3055\u304c\u6c42\u3081\u3089\u308c\u305f<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Java Vector \u30af\u30e9\u30b9\u304b\u3089\u306e\u5f71\u97ff<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>Java\u306eVector\u30af\u30e9\u30b9\u3068\u540c\u69d8\u306e\u6a5f\u80fd\u3092.NET\u3067\u3082\u5b9f\u73fe<\/li>\n\n\n\n<li>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6a19\u6e96\u7684\u306a\u6a5f\u80fd\u3068\u3057\u3066\u5b9f\u88c5<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u767b\u5834\u4ee5\u524d\u306e\u8a2d\u8a08<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>C# 2.0\u3067\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u304c\u5c0e\u5165\u3055\u308c\u308b\u4ee5\u524d\u306e\u8a2d\u8a08<\/li>\n\n\n\n<li>object\u578b\u3092\u4f7f\u7528\u3057\u305f\u6c4e\u7528\u7684\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5b9f\u88c5<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div>\n\n\n\n<p>\u3057\u304b\u3057\u3001.NET Framework 2.0\u4ee5\u964d\u3001\u4ee5\u4e0b\u306e\u7406\u7531\u306b\u3088\u308a\u3001ArrayList\u306e\u4f7f\u7528\u306f\u5f90\u3005\u306b\u6e1b\u5c11\u3057\u3066\u3044\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b8\u30a7\u30cd\u30ea\u30c3\u30af<code>List&lt;T&gt;<\/code>\u306e\u5c0e\u5165\u306b\u3088\u308b\u578b\u5b89\u5168\u6027\u306e\u5411\u4e0a<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316\uff08\u30dc\u30c3\u30af\u30b9\u5316\/\u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u306e\u56de\u907f\uff09<\/li>\n\n\n\n<li>\u30b3\u30fc\u30c9\u4fdd\u5b88\u6027\u3068\u30c7\u30d0\u30c3\u30b0\u306e\u5bb9\u6613\u3055\u306e\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<p>\u73fe\u4ee3\u306eC#\u958b\u767a\u3067\u306f\u3001\u7279\u5225\u306a\u8981\u4ef6\u304c\u306a\u3044\u9650\u308a\u3001<code>List&lt;T&gt;<\/code>\u306e\u4f7f\u7528\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u30ec\u30ac\u30b7\u30fc\u30b7\u30b9\u30c6\u30e0\u306e\u4fdd\u5b88\u3084\u7279\u6b8a\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u304a\u3044\u3066\u3001ArrayList\u306e\u77e5\u8b58\u306f\u4f9d\u7136\u3068\u3057\u3066\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-5\">ArrayList\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u30de\u30b9\u30bf\u30fc\u30ac\u30a4\u30c9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">ArrayList\u306e\u521d\u671f\u5316\u3068\u8981\u7d20\u306e\u8ffd\u52a0\u65b9\u6cd5<\/h3>\n\n\n\n<p>ArrayList\u306e\u521d\u671f\u5316\u306b\u306f\u8907\u6570\u306e\u65b9\u6cd5\u304c\u3042\u308a\u3001\u7528\u9014\u306b\u5fdc\u3058\u3066\u6700\u9069\u306a\u65b9\u6cd5\u3092\u9078\u629e\u3067\u304d\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306b\u4e3b\u8981\u306a\u521d\u671f\u5316\u65b9\u6cd5\u3068\u8981\u7d20\u306e\u8ffd\u52a0\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System;\nusing System.Collections;\n\npublic class ArrayListInitializationDemo\n{\n    public static void Main()\n    {\n        \/\/ 1. \u30c7\u30d5\u30a9\u30eb\u30c8\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u4f7f\u7528\u3057\u305f\u521d\u671f\u5316\n        ArrayList list1 = new ArrayList();\n\n        \/\/ 2. \u521d\u671f\u5bb9\u91cf\u3092\u6307\u5b9a\u3057\u305f\u521d\u671f\u5316\n        ArrayList list2 = new ArrayList(50);  \/\/ \u521d\u671f\u5bb9\u91cf50\u3067\u4f5c\u6210\n\n        \/\/ 3. \u65e2\u5b58\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089\u521d\u671f\u5316\n        int[] numbers = { 1, 2, 3, 4, 5 };\n        ArrayList list3 = new ArrayList(numbers);\n\n        \/\/ \u8981\u7d20\u306e\u8ffd\u52a0\u65b9\u6cd5\n        \/\/ 1. \u5358\u4e00\u8981\u7d20\u306e\u8ffd\u52a0\n        list1.Add(\"First Item\");\n\n        \/\/ 2. \u8907\u6570\u8981\u7d20\u306e\u4e00\u62ec\u8ffd\u52a0\n        list1.AddRange(new string[] { \"Second\", \"Third\", \"Fourth\" });\n\n        \/\/ 3. \u6307\u5b9a\u4f4d\u7f6e\u3078\u306e\u633f\u5165\n        list1.Insert(1, \"Inserted Item\");\n\n        \/\/ 4. \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u6307\u5b9a\u4f4d\u7f6e\u3078\u306e\u4e00\u62ec\u633f\u5165\n        list1.InsertRange(2, new string[] { \"A\", \"B\", \"C\" });\n\n        \/\/ \u5bb9\u91cf\u306e\u6700\u9069\u5316\n        list1.TrimToSize();  \/\/ \u672a\u4f7f\u7528\u306e\u5bb9\u91cf\u3092\u89e3\u653e\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u8981\u7d20\u306e\u53d6\u5f97\u3068\u578b\u30ad\u30e3\u30b9\u30c8\u306e\u6ce8\u610f\u70b9<\/h3>\n\n\n\n<p>ArrayList\u304b\u3089\u8981\u7d20\u3092\u53d6\u5f97\u3059\u308b\u969b\u306f\u3001\u9069\u5207\u306a\u578b\u30ad\u30e3\u30b9\u30c8\u304c\u5fc5\u8981\u3067\u3059\u3002<br>\u4ee5\u4e0b\u306b\u5b89\u5168\u306a\u8981\u7d20\u53d6\u5f97\u65b9\u6cd5\u3068\u6ce8\u610f\u70b9\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ArrayListAccessDemo\n{\n    public static void ShowArrayListAccess()\n    {\n        ArrayList mixedList = new ArrayList();\n        mixedList.Add(100);\n        mixedList.Add(\"Hello\");\n        mixedList.Add(3.14);\n\n        \/\/ 1. \u57fa\u672c\u7684\u306a\u578b\u30ad\u30e3\u30b9\u30c8\n        try\n        {\n            int number = (int)mixedList[0];\n            string text = (string)mixedList[1];\n            double value = (double)mixedList[2];\n\n            \/\/ \u5371\u967a\u306a\u578b\u30ad\u30e3\u30b9\u30c8\uff08\u5b9f\u884c\u6642\u30a8\u30e9\u30fc\u306e\u53ef\u80fd\u6027\uff09\n            string invalidCast = (string)mixedList[0];  \/\/ InvalidCastException\n        }\n        catch (InvalidCastException ex)\n        {\n            Console.WriteLine(\"\u578b\u30ad\u30e3\u30b9\u30c8\u30a8\u30e9\u30fc: \" + ex.Message);\n        }\n\n        \/\/ 2. as\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305f\u5b89\u5168\u306a\u578b\u30ad\u30e3\u30b9\u30c8\uff08\u53c2\u7167\u578b\u306e\u307f\uff09\n        string safeString = mixedList[1] as string;\n        if (safeString != null)\n        {\n            Console.WriteLine(\"\u5b89\u5168\u306b\u6587\u5b57\u5217\u3092\u53d6\u5f97: \" + safeString);\n        }\n\n        \/\/ 3. is\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305f\u578b\u30c1\u30a7\u30c3\u30af\n        if (mixedList[0] is int)\n        {\n            int safeNumber = (int)mixedList[0];\n            Console.WriteLine(\"\u5b89\u5168\u306b\u6570\u5024\u3092\u53d6\u5f97: \" + safeNumber);\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u8981\u7d20\u306e\u524a\u9664\u3068\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u64cd\u4f5c\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>ArrayList\u306e\u8981\u7d20\u524a\u9664\u3068\u52b9\u7387\u7684\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u64cd\u4f5c\u306b\u3064\u3044\u3066\u3001\u4ee5\u4e0b\u306b\u4e3b\u8981\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ArrayListOperationsDemo\n{\n    public static void ShowArrayListOperations()\n    {\n        ArrayList list = new ArrayList() { 1, 2, 3, 4, 5, 3, 6, 7, 3, 8 };\n\n        \/\/ 1. \u7279\u5b9a\u306e\u8981\u7d20\u306e\u524a\u9664\n        list.Remove(3);  \/\/ \u6700\u521d\u306b\u898b\u3064\u304b\u3063\u305f3\u3092\u524a\u9664\n\n        \/\/ 2. \u6307\u5b9a\u4f4d\u7f6e\u306e\u8981\u7d20\u3092\u524a\u9664\n        list.RemoveAt(2);\n\n        \/\/ 3. \u7bc4\u56f2\u6307\u5b9a\u3067\u306e\u524a\u9664\n        list.RemoveRange(1, 3);  \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b91\u304b\u30893\u500b\u306e\u8981\u7d20\u3092\u524a\u9664\n\n        \/\/ 4. \u6761\u4ef6\u306b\u57fa\u3065\u304f\u524a\u9664\n        \/\/ \u5076\u6570\u3092\u3059\u3079\u3066\u524a\u9664\n        for (int i = list.Count - 1; i &gt;= 0; i--)\n        {\n            if ((int)list[i] % 2 == 0)\n            {\n                list.RemoveAt(i);\n            }\n        }\n\n        \/\/ 5. \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5168\u4f53\u306e\u64cd\u4f5c\n        \/\/ \u30bd\u30fc\u30c8\n        list.Sort();\n\n        \/\/ \u9006\u9806\n        list.Reverse();\n\n        \/\/ \u914d\u5217\u3078\u306e\u5909\u63db\n        object[] array = list.ToArray();\n\n        \/\/ \u8981\u7d20\u306e\u691c\u7d22\n        int index = list.IndexOf(5);  \/\/ \u50245\u306e\u6700\u521d\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u5f97\n\n        \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u30af\u30ea\u30a2\n        list.Clear();  \/\/ \u3059\u3079\u3066\u306e\u8981\u7d20\u3092\u524a\u9664\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u64cd\u4f5c\u6642\u306e\u6ce8\u610f\u70b9<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<p class=\"is-style-sango-paragraph-memo\">\u53cd\u5fa9\u51e6\u7406\u4e2d\u306e\u8981\u7d20\u524a\u9664\u306f\u5f8c\u308d\u304b\u3089\u884c\u3046\uff08\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u305a\u308c\u3092\u9632\u3050\u305f\u3081\uff09<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-memo\">\u5927\u91cf\u306e\u8981\u7d20\u3092\u6271\u3046\u5834\u5408\u306f\u3001RemoveRange\u3092\u4f7f\u7528\u3057\u3066\u52b9\u7387\u5316<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-memo\">\u983b\u7e41\u306a\u8ffd\u52a0\/\u524a\u9664\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u5b9a\u671f\u7684\u306bTrimToSize\u3092\u547c\u3073\u51fa\u3057\u3066\u30e1\u30e2\u30ea\u3092\u6700\u9069\u5316<\/p>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u64cd\u4f5c\u3092\u7406\u89e3\u3057\u3001\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001ArrayList\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002\u7279\u306b\u3001\u578b\u306e\u5b89\u5168\u6027\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u306a\u304c\u3089\u3001\u76ee\u7684\u306b\u5fdc\u3058\u305f\u6700\u9069\u306a\u64cd\u4f5c\u65b9\u6cd5\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">ArrayList\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u7279\u6027\u3092\u5fb9\u5e95\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3068\u52d5\u7684\u306a\u914d\u5217\u62e1\u5f35\u306e\u4ed5\u7d44\u307f<\/h3>\n\n\n\n<p>ArrayList\u306e\u5185\u90e8\u5b9f\u88c5\u306f\u52d5\u7684\u914d\u5217\u306b\u57fa\u3065\u3044\u3066\u304a\u308a\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3068\u6027\u80fd\u306b\u95a2\u3057\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System;\nusing System.Collections;\nusing System.Diagnostics;\n\npublic class ArrayListMemoryDemo\n{\n    public static void DemonstrateMemoryBehavior()\n    {\n        ArrayList list = new ArrayList();\n        long initialMemory = GC.GetTotalMemory(true);\n\n        \/\/ \u8981\u7d20\u8ffd\u52a0\u6642\u306e\u5bb9\u91cf\u5909\u5316\u3092\u89b3\u5bdf\n        Console.WriteLine(\"\u521d\u671f\u5bb9\u91cf: \" + list.Capacity);\n\n        for (int i = 0; i &lt; 100; i++)\n        {\n            list.Add(i);\n            if (i % 10 == 0)\n            {\n                Console.WriteLine($\"\u8981\u7d20\u6570: {list.Count}, \u5bb9\u91cf: {list.Capacity}\");\n            }\n        }\n\n        long finalMemory = GC.GetTotalMemory(true);\n        Console.WriteLine($\"\u30e1\u30e2\u30ea\u5897\u52a0\u91cf: {finalMemory - initialMemory} bytes\");\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u5185\u90e8\u52d5\u4f5c\u306e\u7279\u5fb4<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u671f\u5bb9\u91cf<\/strong>: \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f4\u8981\u7d20\u5206<\/li>\n\n\n\n<li><strong>\u62e1\u5f35\u4fc2\u6570<\/strong>: \u5bb9\u91cf\u4e0d\u8db3\u6642\u306b\u73fe\u5728\u306e\u5bb9\u91cf\u306e2\u500d\u306b\u62e1\u5f35<\/li>\n\n\n\n<li><strong>\u30e1\u30e2\u30ea\u52b9\u7387<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u4e88\u6e2c\u53ef\u80fd\u306a\u8981\u7d20\u6570\u306e\u5834\u5408\u306f\u521d\u671f\u5bb9\u91cf\u6307\u5b9a\u304c\u52b9\u7387\u7684<\/li>\n\n\n\n<li>\u4e0d\u8981\u306a\u518d\u914d\u7f6e\u3092\u9632\u3050\u305f\u3081\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u4f59\u5270\u5bb9\u91cf\u3092\u7dad\u6301<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u578b\u5b89\u5168\u6027\u306b\u304a\u3051\u308b\u5236\u7d04\u3068\u5b9f\u884c\u6642\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9<\/h3>\n\n\n\n<p>ArrayList\u306e\u578b\u5b89\u5168\u6027\u306b\u95a2\u3059\u308b\u5236\u7d04\u3068\u305d\u308c\u306b\u4f34\u3046\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff\u3092\u691c\u8a3c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ArrayListTypeOverheadDemo\n{\n    public static void ComparePerformance()\n    {\n        const int itemCount = 1000000;\n\n        \/\/ ArrayList\uff08\u5024\u578b\u3092\u4f7f\u7528\uff09\n        Stopwatch sw = new Stopwatch();\n        sw.Start();\n\n        ArrayList arrayList = new ArrayList();\n        for (int i = 0; i &lt; itemCount; i++)\n        {\n            arrayList.Add(i);  \/\/ \u30dc\u30c3\u30af\u30b9\u5316\u304c\u767a\u751f\n        }\n\n        int sum = 0;\n        foreach (object item in arrayList)\n        {\n            sum += (int)item;  \/\/ \u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u304c\u767a\u751f\n        }\n\n        sw.Stop();\n        Console.WriteLine($\"ArrayList\u51e6\u7406\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n\n        \/\/ \u6bd4\u8f03\u7528\uff1a\u901a\u5e38\u306e\u914d\u5217\n        sw.Restart();\n\n        int[] array = new int[itemCount];\n        for (int i = 0; i &lt; itemCount; i++)\n        {\n            array[i] = i;  \/\/ \u30dc\u30c3\u30af\u30b9\u5316\u306a\u3057\n        }\n\n        sum = 0;\n        foreach (int item in array)\n        {\n            sum += item;  \/\/ \u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u306a\u3057\n        }\n\n        sw.Stop();\n        Console.WriteLine($\"\u901a\u5e38\u914d\u5217\u51e6\u7406\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff\u8981\u56e0<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u30dc\u30c3\u30af\u30b9\u5316\/\u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u5024\u578b\u306e\u683c\u7d0d\u6642\u306b\u767a\u751f\u3059\u308b\u30dc\u30c3\u30af\u30b9\u5316<\/li>\n\n\n\n<li>\u53d6\u308a\u51fa\u3057\u6642\u306b\u767a\u751f\u3059\u308b\u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u5272\u308a\u5f53\u3066\u3068\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8ca0\u8377<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u578b\u30c1\u30a7\u30c3\u30af\u306e\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u5b9f\u884c\u6642\u306e\u578b\u30ad\u30e3\u30b9\u30c8\u306b\u3088\u308b\u51e6\u7406\u8ca0\u8377<\/li>\n\n\n\n<li>\u578b\u30c1\u30a7\u30c3\u30af\u5931\u6557\u6642\u306e\u4f8b\u5916\u51e6\u7406\u30b3\u30b9\u30c8<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u51e6\u7406\u6642\u306e\u6ce8\u610f\u70b9<\/h3>\n\n\n\n<p>\u5927\u91cf\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046\u969b\u306eArrayList\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u7279\u6027\u3068\u6700\u9069\u5316\u6226\u7565\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class LargeDataProcessingDemo\n{\n    public static void ProcessLargeData()\n    {\n        const int largeSize = 1000000;\n        ArrayList largeList = new ArrayList(largeSize);  \/\/ \u521d\u671f\u5bb9\u91cf\u3092\u6307\u5b9a\n\n        \/\/ 1. \u8ffd\u52a0\u64cd\u4f5c\u306e\u6700\u9069\u5316\n        Stopwatch sw = new Stopwatch();\n        sw.Start();\n\n        \/\/ \u30d0\u30c3\u30c1\u51e6\u7406\u306b\u3088\u308b\u8ffd\u52a0\n        object[] batch = new object[10000];\n        for (int i = 0; i &lt; batch.Length; i++)\n        {\n            batch[i] = i;\n        }\n        largeList.AddRange(batch);  \/\/ \u30d0\u30c3\u30c1\u8ffd\u52a0\n\n        sw.Stop();\n        Console.WriteLine($\"\u30d0\u30c3\u30c1\u8ffd\u52a0\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n\n        \/\/ 2. \u691c\u7d22\u64cd\u4f5c\u306e\u6700\u9069\u5316\n        sw.Restart();\n\n        \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30d9\u30fc\u30b9\u306e\u30a2\u30af\u30bb\u30b9\n        for (int i = 0; i &lt; largeList.Count; i++)\n        {\n            object item = largeList[i];\n            \/\/ \u51e6\u7406\n        }\n\n        sw.Stop();\n        Console.WriteLine($\"\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30a2\u30af\u30bb\u30b9\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u51e6\u7406\u6642\u306e\u6700\u9069\u5316\u30dd\u30a4\u30f3\u30c8<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u7ba1\u7406<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u521d\u671f\u5bb9\u91cf\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u5b9a\u671f\u7684\u306aTrimToSize()\u547c\u3073\u51fa\u3057<\/li>\n\n\n\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6d3b\u7528<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u51e6\u7406\u901f\u5ea6\u306e\u6700\u9069\u5316<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30d9\u30fc\u30b9\u306e\u30a2\u30af\u30bb\u30b9\u512a\u5148<\/li>\n\n\n\n<li>\u53cd\u5fa9\u51e6\u7406\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u5fc5\u8981\u306b\u5fdc\u3058\u305f\u30bd\u30fc\u30c8\u6e08\u307f\u72b6\u614b\u306e\u7dad\u6301<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u5206\u5272\u51e6\u7406<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u8003\u616e<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u7279\u6027\u3092\u7406\u89e3\u3057\u3001\u9069\u5207\u306a\u5bfe\u7b56\u3092\u8b1b\u3058\u308b\u3053\u3068\u3067\u3001ArrayList\u3092\u4f7f\u7528\u3059\u308b\u969b\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u9069\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-13\">\u73fe\u4ee3\u306eC#\u958b\u767a\uff1aArrayList\u304b\u3089\u6700\u65b0\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3078\u306e\u79fb\u884c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\"><code>List&lt;T&gt;<\/code>\u306b\u3088\u308b\u578b\u5b89\u5168\u6027\u306e\u78ba\u4fdd\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/h3>\n\n\n\n<p><code>List&lt;T&gt;<\/code>\u306f\u3001ArrayList\u306e\u73fe\u4ee3\u7684\u306a\u5f8c\u7d99\u3067\u3042\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5229\u70b9\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\npublic class ModernCollectionDemo\n{\n    public static void CompareCollections()\n    {\n        \/\/ ArrayList vs List&lt;T&gt;\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\n        const int itemCount = 1000000;\n\n        \/\/ ArrayList\n        Stopwatch sw = new Stopwatch();\n        sw.Start();\n\n        ArrayList arrayList = new ArrayList();\n        for (int i = 0; i &lt; itemCount; i++)\n        {\n            arrayList.Add(i);  \/\/ \u30dc\u30c3\u30af\u30b9\u5316\u304c\u767a\u751f\n        }\n\n        int sumArrayList = 0;\n        foreach (object item in arrayList)\n        {\n            sumArrayList += (int)item;  \/\/ \u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u304c\u767a\u751f\n        }\n\n        sw.Stop();\n        Console.WriteLine($\"ArrayList\u51e6\u7406\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n\n        \/\/ List&lt;T&gt;\n        sw.Restart();\n\n        List&lt;int&gt; genericList = new List&lt;int&gt;();\n        for (int i = 0; i &lt; itemCount; i++)\n        {\n            genericList.Add(i);  \/\/ \u30dc\u30c3\u30af\u30b9\u5316\u306a\u3057\n        }\n\n        int sumGenericList = 0;\n        foreach (int item in genericList)\n        {\n            sumGenericList += item;  \/\/ \u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u306a\u3057\n        }\n\n        sw.Stop();\n        Console.WriteLine($\"List&lt;T&gt;\u51e6\u7406\u6642\u9593: {sw.ElapsedMilliseconds}ms\");\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\"><code>List&lt;T&gt;<\/code>\u306e\u4e3b\u306a\u5229\u70b9<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u578b\u5b89\u5168\u6027<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u578b\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li>\u578b\u30ad\u30e3\u30b9\u30c8\u306e\u5fc5\u8981\u6027\u3092\u6392\u9664<\/li>\n\n\n\n<li>\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30a8\u30e9\u30fc\u306e\u65e9\u671f\u767a\u898b<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u30dc\u30c3\u30af\u30b9\u5316\/\u30a2\u30f3\u30dc\u30c3\u30af\u30b9\u5316\u306e\u56de\u907f<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u52b9\u7387\u306e\u5411\u4e0a<\/li>\n\n\n\n<li>\u5b9f\u884c\u6642\u30aa\u30fc\u30d0\u30fc\u30d8\u30c3\u30c9\u306e\u524a\u6e1b<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u30ec\u30ac\u30b7\u30fc\u30b3\u30fc\u30c9\u306e\u5b89\u5168\u306a\u79fb\u884c\u624b\u9806<\/h3>\n\n\n\n<p>\u65e2\u5b58\u306eArrayList\u30b3\u30fc\u30c9\u3092<code>List&lt;T&gt;<\/code>\u306b\u79fb\u884c\u3059\u308b\u969b\u306e\u63a8\u5968\u624b\u9806\u3068\u6ce8\u610f\u70b9\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class MigrationDemo\n{\n    \/\/ \u79fb\u884c\u524d\u306e\u30ec\u30ac\u30b7\u30fc\u30b3\u30fc\u30c9\n    public class LegacyClass\n    {\n        private ArrayList items = new ArrayList();\n\n        public void AddItem(object item)\n        {\n            items.Add(item);\n        }\n\n        public object GetItem(int index)\n        {\n            return items[index];\n        }\n    }\n\n    \/\/ \u79fb\u884c\u5f8c\u306e\u30e2\u30c0\u30f3\u306a\u5b9f\u88c5\n    public class ModernClass&lt;T&gt;\n    {\n        private List&lt;T&gt; items = new List&lt;T&gt;();\n\n        public void AddItem(T item)\n        {\n            items.Add(item);\n        }\n\n        public T GetItem(int index)\n        {\n            return items[index];\n        }\n\n        \/\/ \u65e2\u5b58\u306eArrayList\u304b\u3089\u306e\u5909\u63db\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n        public ModernClass(ArrayList legacy)\n        {\n            foreach (object item in legacy)\n            {\n                if (item is T typedItem)\n                {\n                    items.Add(typedItem);\n                }\n            }\n        }\n    }\n\n    \/\/ \u6bb5\u968e\u7684\u306a\u79fb\u884c\u306e\u4f8b\n    public static void DemonstrateMigration()\n    {\n        \/\/ 1. \u65e2\u5b58\u306eArrayList\u30c7\u30fc\u30bf\n        ArrayList legacy = new ArrayList { 1, 2, 3, 4, 5 };\n\n        \/\/ 2. \u79fb\u884c\u306e\u305f\u3081\u306e\u4e00\u6642\u7684\u306a\u4e92\u63db\u6027\u30ec\u30a4\u30e4\u30fc\n        List&lt;int&gt; modern = legacy.Cast&lt;object&gt;()\n                                .Where(x =&gt; x is int)\n                                .Select(x =&gt; (int)x)\n                                .ToList();\n\n        \/\/ 3. \u65b0\u3057\u3044\u30b3\u30fc\u30c9\u3067\u306e\u4f7f\u7528\n        ModernClass&lt;int&gt; modernClass = new ModernClass&lt;int&gt;(legacy);\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u79fb\u884c\u624b\u9806\u306e\u30dd\u30a4\u30f3\u30c8<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<p class=\"is-style-sango-paragraph-idea-alt\">1. \u578b\u306e\u7279\u5b9a\u3068\u6574\u7406<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">2. \u6bb5\u968e\u7684\u306a\u79fb\u884c\u8a08\u753b\u306e\u7acb\u6848<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">3. \u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u4f5c\u6210<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">4. \u4e92\u63db\u6027\u30ec\u30a4\u30e4\u30fc\u306e\u5b9f\u88c5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">5. \u30b3\u30fc\u30c9\u306e\u6bb5\u968e\u7684\u306a\u7f6e\u304d\u63db\u3048<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u79fb\u884c\u5f8c\u306e\u30b3\u30fc\u30c9\u54c1\u8cea\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u5411\u4e0a<\/h3>\n\n\n\n<p><code>List&lt;T&gt;<\/code>\u3078\u306e\u79fb\u884c\u306b\u3088\u3063\u3066\u5f97\u3089\u308c\u308b\u54c1\u8cea\u5411\u4e0a\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u6539\u5584\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class CodeQualityDemo\n{\n    \/\/ \u79fb\u884c\u524d\uff1a\u578b\u5b89\u5168\u6027\u304c\u4f4e\u304f\u3001\u30d0\u30b0\u304c\u767a\u751f\u3057\u3084\u3059\u3044\u5b9f\u88c5\n    public class LegacyInventory\n    {\n        private ArrayList items = new ArrayList();\n\n        public void AddProduct(object product)\n        {\n            items.Add(product);  \/\/ \u578b\u30c1\u30a7\u30c3\u30af\u306a\u3057\n        }\n\n        public decimal CalculateTotal()\n        {\n            decimal total = 0;\n            foreach (object item in items)\n            {\n                \/\/ \u5b9f\u884c\u6642\u30a8\u30e9\u30fc\u306e\u53ef\u80fd\u6027\u3042\u308a\n                if (item is Product p)\n                {\n                    total += p.Price;\n                }\n            }\n            return total;\n        }\n    }\n\n    \/\/ \u79fb\u884c\u5f8c\uff1a\u578b\u5b89\u5168\u3067\u4fdd\u5b88\u6027\u306e\u9ad8\u3044\u5b9f\u88c5\n    public class ModernInventory\n    {\n        private List&lt;Product&gt; items = new List&lt;Product&gt;();\n\n        public void AddProduct(Product product)\n        {\n            items.Add(product);  \/\/ \u578b\u5b89\u5168\u6027\u304c\u4fdd\u8a3c\u3055\u308c\u308b\n        }\n\n        public decimal CalculateTotal()\n        {\n            \/\/ LINQ\u3092\u4f7f\u7528\u3057\u305f\u7c21\u6f54\u3067\u8aad\u307f\u3084\u3059\u3044\u5b9f\u88c5\n            return items.Sum(p =&gt; p.Price);\n        }\n\n        \/\/ \u62e1\u5f35\u6027\u306e\u9ad8\u3044\u6a5f\u80fd\u8ffd\u52a0\u304c\u5bb9\u6613\n        public IEnumerable&lt;Product&gt; GetProductsByCategory(string category)\n        {\n            return items.Where(p =&gt; p.Category == category);\n        }\n    }\n\n    public class Product\n    {\n        public string Name { get; set; }\n        public decimal Price { get; set; }\n        public string Category { get; set; }\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u79fb\u884c\u5f8c\u306e\u6539\u5584\u70b9<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u4fe1\u983c\u6027<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u578b\u30a8\u30e9\u30fc\u306e\u9632\u6b62<\/li>\n\n\n\n<li>\u30d0\u30b0\u306e\u65e9\u671f\u767a\u898b<\/li>\n\n\n\n<li>\u4f8b\u5916\u51e6\u7406\u306e\u524a\u6e1b<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4fdd\u5b88\u6027\u306e\u5411\u4e0a<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u5411\u4e0a<\/li>\n\n\n\n<li>\u30c7\u30d0\u30c3\u30b0\u306e\u5bb9\u6613\u3055<\/li>\n\n\n\n<li>\u6a5f\u80fd\u62e1\u5f35\u306e\u7c21\u6613\u5316<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u958b\u767a\u52b9\u7387<\/strong>\n<ul class=\"wp-block-list\">\n<li>IDE\u306e\u30b5\u30dd\u30fc\u30c8\u5411\u4e0a<\/li>\n\n\n\n<li>\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u5bb9\u6613\u3055<\/li>\n\n\n\n<li>\u30c1\u30fc\u30e0\u958b\u767a\u306e\u52b9\u7387\u5316<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-17\">ArrayList\u306e\u6d3b\u7528\u30b7\u30fc\u30f3\u3068\u4ee3\u66ff\u624b\u6bb5\u306e\u9078\u629e\u57fa\u6e96<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">ArrayList\u304c\u4f9d\u7136\u3068\u3057\u3066\u6709\u52b9\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u73fe\u4ee3\u306eC#\u958b\u767a\u306b\u304a\u3044\u3066\u3082\u3001ArrayList\u304c\u9069\u3057\u3066\u3044\u308b\u7279\u6b8a\u306a\u30b1\u30fc\u30b9\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using System;\nusing System.Collections;\nusing System.Collections.Generic;\n\npublic class ValidUseCasesDemo\n{\n    \/\/ 1. \u52d5\u7684\u306a\u578b\u6df7\u5728\u304c\u5fc5\u8981\u306a\u30b1\u30fc\u30b9\n    public class DynamicDataContainer\n    {\n        private ArrayList mixedData = new ArrayList();\n\n        public void AddData(object data)\n        {\n            mixedData.Add(data);\n        }\n\n        public void ProcessData()\n        {\n            foreach (object item in mixedData)\n            {\n                switch (item)\n                {\n                    case int i:\n                        Console.WriteLine($\"\u6570\u5024\u51e6\u7406: {i}\");\n                        break;\n                    case string s:\n                        Console.WriteLine($\"\u6587\u5b57\u5217\u51e6\u7406: {s}\");\n                        break;\n                    case DateTime d:\n                        Console.WriteLine($\"\u65e5\u4ed8\u51e6\u7406: {d}\");\n                        break;\n                }\n            }\n        }\n    }\n\n    \/\/ 2. \u30ec\u30ac\u30b7\u30fc\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u7d71\u5408\n    public class LegacySystemBridge\n    {\n        private readonly ArrayList legacyData;\n\n        public LegacySystemBridge(ArrayList data)\n        {\n            this.legacyData = data;\n        }\n\n        \/\/ \u65b0\u30b7\u30b9\u30c6\u30e0\u306e\u30c7\u30fc\u30bf\u5f62\u5f0f\u306b\u5909\u63db\n        public List&lt;T&gt; ConvertToModern&lt;T&gt;()\n        {\n            return new List&lt;T&gt;(legacyData.Cast&lt;T&gt;());\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-19\">ArrayList\u304c\u9069\u3057\u3066\u3044\u308b\u72b6\u6cc1<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9f\u884c\u6642\u306b\u578b\u304c\u52d5\u7684\u306b\u5909\u5316\u3059\u308b\u30c7\u30fc\u30bf\u69cb\u9020\u304c\u5fc5\u8981\u306a\u5834\u5408<\/li>\n\n\n\n<li>\u30ec\u30ac\u30b7\u30fc\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u4e92\u63db\u6027\u7dad\u6301\u304c\u5fc5\u8981\u306a\u5834\u5408<\/li>\n\n\n\n<li>\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u591a\u7528\u3059\u308b\u7279\u6b8a\u306a\u30b1\u30fc\u30b9<\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u306e\u52d5\u7684\u578b\u51e6\u7406<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8981\u4ef6\u306b\u5fdc\u3058\u305f\u6700\u9069\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e<\/h3>\n\n\n\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7279\u6027\u306b\u5fdc\u3058\u3066\u3001\u6700\u9069\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u9078\u629e\u3059\u308b\u57fa\u6e96\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class CollectionSelectionDemo\n{\n    \/\/ \u5404\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u578b\u306e\u7279\u6027\u6bd4\u8f03\n    public class CollectionComparison\n    {\n        \/\/ 1. \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u91cd\u8981\u306a\u5834\u5408\n        public void PerformanceCriticalOperation()\n        {\n            \/\/ \u56fa\u5b9a\u30b5\u30a4\u30ba\u306e\u914d\u5217\u304c\u6700\u9069\n            int[] array = new int[1000000];\n\n            \/\/ \u307e\u305f\u306f\u578b\u6307\u5b9a\u30ea\u30b9\u30c8\n            List&lt;int&gt; list = new List&lt;int&gt;(1000000);\n        }\n\n        \/\/ 2. \u8981\u7d20\u306e\u8ffd\u52a0\/\u524a\u9664\u304c\u983b\u7e41\u306a\u5834\u5408\n        public void FrequentModificationOperation()\n        {\n            \/\/ LinkedList\u304c\u52b9\u7387\u7684\n            LinkedList&lt;int&gt; linkedList = new LinkedList&lt;int&gt;();\n        }\n\n        \/\/ 3. \u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u304c\u5fc5\u8981\u306a\u5834\u5408\n        public void KeyValueOperation()\n        {\n            \/\/ Dictionary\u304c\u6700\u9069\n            Dictionary&lt;string, object&gt; dict = new Dictionary&lt;string, object&gt;();\n        }\n\n        \/\/ 4. \u30e6\u30cb\u30fc\u30af\u306a\u8981\u7d20\u306e\u307f\u304c\u5fc5\u8981\u306a\u5834\u5408\n        public void UniqueElementsOperation()\n        {\n            \/\/ HashSet\u304c\u52b9\u7387\u7684\n            HashSet&lt;string&gt; uniqueItems = new HashSet&lt;string&gt;();\n        }\n    }\n\n    \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e\u306e\u5224\u65ad\u57fa\u6e96\n    public static class CollectionSelector\n    {\n        public static string GetRecommendation(\n            bool isFixedSize,\n            bool needsKeyValuePairs,\n            bool requiresUniqueItems,\n            bool frequentModification,\n            bool mixedTypes)\n        {\n            if (mixedTypes)\n            {\n                return \"ArrayList (\u8981\u691c\u8a0e: \u4ee3\u66ff\u624b\u6bb5\u306e\u53ef\u80fd\u6027)\";\n            }\n\n            if (isFixedSize)\n            {\n                return \"Array[]\";\n            }\n\n            if (needsKeyValuePairs)\n            {\n                return \"Dictionary&lt;TKey, TValue&gt;\";\n            }\n\n            if (requiresUniqueItems)\n            {\n                return \"HashSet&lt;T&gt;\";\n            }\n\n            if (frequentModification)\n            {\n                return \"LinkedList&lt;T&gt;\";\n            }\n\n            return \"List&lt;T&gt; (\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u63a8\u5968)\";\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">\u5c06\u6765\u3092\u898b\u636e\u3048\u305f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u8a2d\u8a08\u306e\u8003\u3048\u65b9<\/h3>\n\n\n\n<p>\u9577\u671f\u7684\u306a\u4fdd\u5b88\u6027\u3068\u62e1\u5f35\u6027\u3092\u8003\u616e\u3057\u305f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u8a2d\u8a08\u306e\u539f\u5247\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class ModernCollectionDesignDemo\n{\n    \/\/ 1. \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u30d9\u30fc\u30b9\u306e\u8a2d\u8a08\n    public interface IDataCollection&lt;T&gt;\n    {\n        void Add(T item);\n        bool Remove(T item);\n        IEnumerable&lt;T&gt; GetItems();\n    }\n\n    \/\/ 2. \u62bd\u8c61\u5316\u3055\u308c\u305f\u5b9f\u88c5\n    public class ModernDataCollection&lt;T&gt; : IDataCollection&lt;T&gt;\n    {\n        private readonly List&lt;T&gt; items = new List&lt;T&gt;();\n\n        public void Add(T item)\n        {\n            items.Add(item);\n        }\n\n        public bool Remove(T item)\n        {\n            return items.Remove(item);\n        }\n\n        public IEnumerable&lt;T&gt; GetItems()\n        {\n            return items.AsEnumerable();\n        }\n    }\n\n    \/\/ 3. \u62e1\u5f35\u6027\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08\n    public class ExtensibleCollection&lt;T&gt; : ModernDataCollection&lt;T&gt;\n    {\n        private readonly Dictionary&lt;string, Func&lt;IEnumerable&lt;T&gt;, IEnumerable&lt;T&gt;&gt;&gt; \n            filters = new Dictionary&lt;string, Func&lt;IEnumerable&lt;T&gt;, IEnumerable&lt;T&gt;&gt;&gt;();\n\n        public void AddFilter(string name, Func&lt;IEnumerable&lt;T&gt;, IEnumerable&lt;T&gt;&gt; filter)\n        {\n            filters[name] = filter;\n        }\n\n        public IEnumerable&lt;T&gt; GetFilteredItems(string filterName)\n        {\n            var items = GetItems();\n            return filters.TryGetValue(filterName, out var filter)\n                ? filter(items)\n                : items;\n        }\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u8a2d\u8a08\u539f\u5247\u306e\u30dd\u30a4\u30f3\u30c8<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ol class=\"wp-block-list\">\n<li><strong>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u6307\u5411<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u5b9f\u88c5\u306e\u8a73\u7d30\u3092\u96a0\u853d<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u5bb9\u6613\u6027\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u4f9d\u5b58\u6027\u306e\u4f4e\u6e1b<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u62e1\u5f35\u6027\u306e\u78ba\u4fdd<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u65b0\u6a5f\u80fd\u8ffd\u52a0\u306e\u5bb9\u6613\u3055<\/li>\n\n\n\n<li>\u30d0\u30fc\u30b8\u30e7\u30f3\u4e92\u63db\u6027\u306e\u7dad\u6301<\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u6a5f\u69cb\u306e\u30b5\u30dd\u30fc\u30c8<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4fdd\u5b88\u6027\u306e\u91cd\u8996<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30fc\u30c9\u306e\u660e\u78ba\u306a\u69cb\u9020\u5316<\/li>\n\n\n\n<li>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5316\u306e\u5145\u5b9f<\/li>\n\n\n\n<li>\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u306e\u5bb9\u6613\u3055<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u8003\u3048\u65b9\u3092\u57fa\u306b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8981\u4ef6\u3068\u5c06\u6765\u7684\u306a\u5c55\u958b\u3092\u898b\u636e\u3048\u305f\u9069\u5207\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u8a2d\u8a08\u3092\u884c\u3046\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-22\">ArrayList\u306e\u307e\u3068\u3081<\/h2>\n\n\n\n<p>ArrayList\u306f\u67d4\u8edf\u6027\u306e\u9ad8\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3068\u3057\u3066\u9577\u5e74\u6d3b\u7528\u3055\u308c\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u73fe\u4ee3\u306eC#\u958b\u767a\u3067\u306f\u3088\u308a\u578b\u5b89\u5168\u306a<code>List&lt;T&gt;<\/code>\u306a\u3069\u306e\u4ee3\u66ff\u624b\u6bb5\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u3057\u304b\u3057\u3001\u30ec\u30ac\u30b7\u30fc\u30b7\u30b9\u30c6\u30e0\u306e\u4fdd\u5b88\u3084\u7279\u6b8a\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3067\u306f\u3001ArrayList\u306e\u77e5\u8b58\u304c\u4f9d\u7136\u3068\u3057\u3066\u91cd\u8981\u3067\u3059\u3002\u9069\u5207\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e\u3068\u79fb\u884c\u6226\u7565\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u4fdd\u5b88\u6027\u306e\u9ad8\u3044C#\u958b\u767a\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u3053\u306e\u8a18\u4e8b\u306e\u4e3b\u306a\u30dd\u30a4\u30f3\u30c8<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<p class=\"is-style-sango-paragraph-idea-alt\">ArrayList\u306f\u67d4\u8edf\u3060\u304c\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u578b\u5b89\u5168\u6027\u306b\u8ab2\u984c\u304c\u3042\u308b<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u65b0\u898f\u958b\u767a\u3067\u306f<code>List&lt;T&gt;<\/code>\u306a\u3069\u306e\u578b\u4ed8\u304d\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u512a\u5148\u7684\u306b\u691c\u8a0e\u3059\u308b<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30ec\u30ac\u30b7\u30fc\u30b3\u30fc\u30c9\u306e\u4fdd\u5b88\u306b\u306f\u6bb5\u968e\u7684\u306a\u79fb\u884c\u6226\u7565\u304c\u6709\u52b9<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u52d5\u7684\u306a\u578b\u6df7\u5728\u304c\u5fc5\u8981\u306a\u7279\u6b8a\u30b1\u30fc\u30b9\u3067\u306fArrayList\u304c\u4f9d\u7136\u3068\u3057\u3066\u6709\u7528<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u9078\u629e\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8981\u4ef6\u3068\u5c06\u6765\u6027\u3092\u8003\u616e\u3057\u3066\u5224\u65ad\u3059\u308b<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2872,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,61],"tags":[],"class_list":{"0":"post-1632","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-csharp","8":"category-csharp-syntax"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/1632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1632"}],"version-history":[{"count":13,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/1632\/revisions"}],"predecessor-version":[{"id":1645,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/1632\/revisions\/1645"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/media\/2872"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}