{"id":1646,"date":"2024-12-12T18:07:31","date_gmt":"2024-12-12T09:07:31","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=1646"},"modified":"2025-03-24T08:50:13","modified_gmt":"2025-03-23T23:50:13","slug":"c-as%e3%82%ad%e3%83%bc%e3%83%af%e3%83%bc%e3%83%89%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%ae%89%e5%85%a8%e3%81%aa%e5%9e%8b%e5%a4%89%e6%8f%9b%e3%81%a85%e3%81%a4%e3%81%ae%e5%ae%9f","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=1646","title":{"rendered":"C# as\u30ad\u30fc\u30ef\u30fc\u30c9\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u5b89\u5168\u306a\u578b\u5909\u63db\u30685\u3064\u306e\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9"},"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>    <ul class=\"menu_level_1\">      <li class=\"first last\">        <a href=\"#i-1\">\u5171\u901a\u30b3\u30fc\u30c9\u30d9\u30fc\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-2\">C# as\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u306f\uff1a\u57fa\u790e\u304b\u3089\u7406\u89e3\u3059\u308b\u578b\u5909\u63db\u306e\u5473\u65b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-3\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u958b\u767a\u8ab2\u984c<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-7\">as\u6f14\u7b97\u5b50\u3068\u30ad\u30e3\u30b9\u30c8\u6f14\u7b97\u5b50\u306e\u9055\u3044\u3092\u7406\u89e3\u3057\u3088\u3046<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3088\u3046<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u53c2\u7167\u578b\u306b\u5bfe\u3059\u308bas\u6f14\u7b97\u5b50\u306e\u4f7f\u7528\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-11\">nullable\u578b\u3068as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u95a2\u4fc2\u6027<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-12\">as\u6f14\u7b97\u5b50\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9\u3068\u5236\u9650\u4e8b\u9805<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-16\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3067\u5b66\u3076as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-17\">\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0\u3092\u6d3b\u7528\u3057\u305f\u30af\u30e9\u30b9\u968e\u5c64\u3067\u306e\u578b\u5909\u63db<\/a>      <\/li>      <li>        <a href=\"#i-18\">\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u5b9f\u88c5\u6642\u306e\u578b\u30c1\u30a7\u30c3\u30af\u3068\u5909\u63db<\/a>      <\/li>      <li>        <a href=\"#i-19\">\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306b\u304a\u3051\u308bas\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528<\/a>      <\/li>      <li>        <a href=\"#i-20\">\u975e\u540c\u671f\u51e6\u7406\u3068as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-21\">\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3067\u306eas\u6f14\u7b97\u5b50\u306e\u4f7f\u7528<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-22\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30b3\u30fc\u30c9\u54c1\u8cea\u306e\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-23\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u3068is\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u4f7f\u3044\u5206\u3051<\/a>      <\/li>      <li>        <a href=\"#i-26\">\u578b\u5909\u63db\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li>        <a href=\"#i-27\">\u5358\u4f53\u30c6\u30b9\u30c8\u306b\u304a\u3051\u308bas\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-28\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-32\">\u3088\u304f\u3042\u308b\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3068\u56de\u907f\u65b9\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-33\">\u4f8b\u5916\u51e6\u7406\u306e\u4ee3\u7528\u3068\u3057\u3066\u306e\u8aa4\u3063\u305f\u4f7f\u7528<\/a>      <\/li>      <li>        <a href=\"#i-35\">\u4e0d\u5fc5\u8981\u306a\u578b\u5909\u63db\u306e\u9023\u9396\u3092\u907f\u3051\u308b<\/a>      <\/li>      <li>        <a href=\"#i-37\">null\u53c2\u7167\u306e\u5b89\u5168\u306a\u51e6\u7406\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-39\">\u6539\u5584\u306e\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-42\">C# 12\u3067\u306e\u65b0\u6a5f\u80fd\u3068\u5c06\u6765\u306e\u5c55\u671b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-43\">\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306e\u578b\u5909\u63db\u6a5f\u80fd\u306e\u9032\u5316<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-46\">\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306e\u767a\u5c55\u3068\u4eca\u5f8c\u306e\u53ef\u80fd\u6027<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-50\">as\u30ad\u30fc\u30ef\u30fc\u30c9\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#\u3067\u306e\u578b\u5909\u63db\u306f\u958b\u767a\u8005\u304c\u65e5\u5e38\u7684\u306b\u76f4\u9762\u3059\u308b\u8ab2\u984c\u3067\u3059\u3002\u7279\u306b<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306f\u3001\u5b89\u5168\u306a\u578b\u5909\u63db\u3092\u5b9f\u73fe\u3059\u308b\u91cd\u8981\u306a\u8a00\u8a9e\u6a5f\u80fd\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002<br>\u672c\u8a18\u4e8b\u3067\u306f\u3001\u5b9f\u8df5\u7684\u306a\u5f62\u72b6\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u3092\u4f8b\u306b\u3001<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u52b9\u679c\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u304b\u3089\u6700\u65b0\u306eC# 12\u3067\u306e\u6d3b\u7528\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\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u3068\u52d5\u4f5c\u539f\u7406<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3067\u306e\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30b3\u30fc\u30c9\u54c1\u8cea\u306e\u6700\u9069\u5316\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u4e00\u822c\u7684\u306a\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3068\u305d\u306e\u56de\u907f\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">C# 12\u3067\u306e\u65b0\u6a5f\u80fd\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u65b9<\/p>\n\n\n\n<p class=\"is-style-sango-paragraph-idea-alt\">\u578b\u5909\u63db\u306b\u95a2\u3059\u308b\u5c06\u6765\u306e\u5c55\u671b<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u5171\u901a\u30b3\u30fc\u30c9\u30d9\u30fc\u30b9<\/h3>\n\n\n\n<p>\u5404\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u4e0b\u8a18\u306e\u5171\u901a\u90e8\u54c1\u3092\u7528\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\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=\"\">namespace ShapeProcessing\n{\n    public interface IShape\n    {\n        double CalculateArea();\n        string Type { get; }\n    }\n\n    public class Circle : IShape\n    {\n        public double Radius { get; set; }\n        public string Type =&gt; \"Circle\";\n        public double CalculateArea() =&gt; Math.PI * Radius * Radius;\n    }\n\n    public class Rectangle : IShape\n    {\n        public double Width { get; set; }\n        public double Height { get; set; }\n        public string Type =&gt; \"Rectangle\";\n        public double CalculateArea() =&gt; Width * Height;\n    }\n\n    public class Triangle : IShape\n    {\n        public double Base { get; set; }\n        public double Height { get; set; }\n        public string Type =&gt; \"Triangle\";\n        public double CalculateArea() =&gt; 0.5 * Base * Height;\n    }\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-2\">C# as\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u306f\uff1a\u57fa\u790e\u304b\u3089\u7406\u89e3\u3059\u308b\u578b\u5909\u63db\u306e\u5473\u65b9<\/h2>\n\n\n\n<p>C#\u3067\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3044\u3066\u3001\u578b\u5909\u63db\u306f\u65e5\u5e38\u7684\u306a\u64cd\u4f5c\u3067\u3059\u3002\u7279\u306b\u5927\u898f\u6a21\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u3067\u306f\u3001\u69d8\u3005\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u9593\u306e\u5b89\u5168\u306a\u578b\u5909\u63db\u304c\u91cd\u8981\u306b\u306a\u308a\u307e\u3059\u3002<br>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u5f62\u72b6\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\u3092\u4f8b\u306b\u3001<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u65b9\u6cd5\u3092\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u958b\u767a\u8ab2\u984c<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-4\">1. <strong>\u4f8b\u5916\u306b\u3088\u308b\u51e6\u7406\u306e\u4e2d\u65ad\u306e\u9632\u6b62<\/strong><\/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=\"\">public class ShapeProcessor\n{\n    public void ProcessShape(object shape)\n    {\n        \/\/ \u5f93\u6765\u306e\u30ad\u30e3\u30b9\u30c8\n        try {\n            var circle = (Circle)shape; \/\/ \u5931\u6557\u6642\u306bInvalidCastException\n            Console.WriteLine($\"Circle area: {circle.CalculateArea()}\");\n        } catch (InvalidCastException) {\n            \/\/ \u4f8b\u5916\u51e6\u7406\u304c\u5fc5\u8981\n        }\n\n        \/\/ as\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\n        var safeCircle = shape as Circle; \/\/ \u5931\u6557\u6642\u306fnull\n        if (safeCircle != null)\n        {\n            Console.WriteLine($\"Circle area: {safeCircle.CalculateArea()}\");\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-5\">2. <strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/strong><\/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=\"\">public class ShapeCollectionProcessor\n{\n    public void ProcessShapes(IEnumerable&lt;object&gt; shapes)\n    {\n        foreach (var shape in shapes)\n        {\n            \/\/ as\u3092\u4f7f\u7528\u3057\u305f\u52b9\u7387\u7684\u306a\u578b\u30c1\u30a7\u30c3\u30af\u3068\u5909\u63db\n            var processableShape = shape as IShape;\n            if (processableShape != null)\n            {\n                Console.WriteLine($\"Processing {processableShape.Type} \" +\n                    $\"with area: {processableShape.CalculateArea()}\");\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-6\">3. <strong>\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u5411\u4e0a<\/strong><\/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=\"\">public class ShapeAnalyzer\n{\n    public double? CalculateTotalArea(object[] shapes)\n    {\n        return shapes\n            .Select(s =&gt; s as IShape)\n            .Where(s =&gt; s != null)\n            .Sum(s =&gt; s!.CalculateArea());\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">as\u6f14\u7b97\u5b50\u3068\u30ad\u30e3\u30b9\u30c8\u6f14\u7b97\u5b50\u306e\u9055\u3044\u3092\u7406\u89e3\u3057\u3088\u3046<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u8868\u306f\u3001\u5b9f\u969b\u306e\u5f62\u72b6\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u4f7f\u7528\u4f8b\u3092\u57fa\u306b\u3001\u5404\u6f14\u7b97\u5b50\u306e\u7279\u5fb4\u3092\u6bd4\u8f03\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n<div id=\"id-529c3ce9-e33b-4646-946b-7db375de74ef\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7279\u6027<\/th><th>as\u6f14\u7b97\u5b50<\/th><th>\u30ad\u30e3\u30b9\u30c8\u6f14\u7b97\u5b50<\/th><\/tr><\/thead><tbody><tr><td>\u5931\u6557\u6642\u306e\u52d5\u4f5c<\/td><td>null\u3092\u8fd4\u3059<\/td><td>\u4f8b\u5916\u3092\u767a\u751f<\/td><\/tr><tr><td>\u4f7f\u7528\u4f8b<\/td><td><code>shape as Circle<\/code><\/td><td><code>(Circle)shape<\/code><\/td><\/tr><tr><td>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5f71\u97ff<\/td><td>\u6700\u5c0f\u9650<\/td><td>\u4f8b\u5916\u767a\u751f\u6642\u306b\u5927\u304d\u3044<\/td><\/tr><tr><td>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/td><td>null \u30c1\u30a7\u30c3\u30af\u3067\u5bfe\u5fdc<\/td><td>try-catch \u304c\u5fc5\u8981<\/td><\/tr><tr><td>\u30b3\u30fc\u30c9\u91cf<\/td><td>\u5c11\u306a\u3044<\/td><td>\u591a\u3044<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"i-8\">\u5b9f\u8df5\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=\"\">public class ShapeValidator\n{\n    public bool ValidateShape(object shape)\n    {\n        \/\/ as\u6f14\u7b97\u5b50\u306b\u3088\u308b\u5b89\u5168\u306a\u578b\u30c1\u30a7\u30c3\u30af\n        var validShape = shape as IShape;\n        if (validShape == null)\n        {\n            return false;\n        }\n\n        \/\/ \u578b\u56fa\u6709\u306e\u691c\u8a3c\n        switch (validShape)\n        {\n            case Circle circle when circle.Radius &gt; 0:\n            case Rectangle rectangle when rectangle.Width &gt; 0 &amp;&amp; rectangle.Height &gt; 0:\n            case Triangle triangle when triangle.Base &gt; 0 &amp;&amp; triangle.Height &gt; 0:\n                return true;\n            default:\n                return false;\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u306e\u57fa\u672c\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u308a\u5b9f\u8df5\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3088\u3046<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u53c2\u7167\u578b\u306b\u5bfe\u3059\u308bas\u6f14\u7b97\u5b50\u306e\u4f7f\u7528\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u5f62\u72b6\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u3092\u4f8b\u306b\u3001\u5b9f\u8df5\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\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 ShapeManager\n{\n    private readonly Dictionary&lt;string, IShape&gt; _shapeCache = new();\n\n    public void RegisterShape(object shape)\n    {\n        \/\/ as\u6f14\u7b97\u5b50\u306b\u3088\u308b\u5b89\u5168\u306a\u578b\u5909\u63db\n        var registrableShape = shape as IShape;\n        if (registrableShape != null)\n        {\n            _shapeCache[registrableShape.Type] = registrableShape;\n            Console.WriteLine($\"Registered {registrableShape.Type}\");\n        }\n    }\n\n    public void ProcessRegisteredShapes()\n    {\n        foreach (var shape in _shapeCache.Values)\n        {\n            \/\/ \u7279\u5b9a\u306e\u5f62\u72b6\u306b\u5bfe\u3059\u308b\u51e6\u7406\n            var circle = shape as Circle;\n            if (circle != null)\n            {\n                Console.WriteLine($\"Circle with radius {circle.Radius}\");\n                continue;\n            }\n\n            var rectangle = shape as Rectangle;\n            if (rectangle != null)\n            {\n                Console.WriteLine($\"Rectangle {rectangle.Width}x{rectangle.Height}\");\n                continue;\n            }\n\n            Console.WriteLine($\"Unknown shape type: {shape.Type}\");\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">nullable\u578b\u3068as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u95a2\u4fc2\u6027<\/h3>\n\n\n\n<p>C# 8.0\u4ee5\u964d\u306eNullable\u53c2\u7167\u578b\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u4f8b\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 ModernShapeProcessor\n{\n    public string? GetShapeDescription(object? shape)\n    {\n        \/\/ null\u8a31\u5bb9\u53c2\u7167\u578b\u3068as\u306e\u7d44\u307f\u5408\u308f\u305b\n        var processableShape = shape as IShape;\n        if (processableShape == null)\n        {\n            return null;\n        }\n\n        return processableShape switch\n        {\n            Circle c =&gt; $\"Circle with area {c.CalculateArea():F2}\",\n            Rectangle r =&gt; $\"Rectangle with area {r.CalculateArea():F2}\",\n            Triangle t =&gt; $\"Triangle with area {t.CalculateArea():F2}\",\n            _ =&gt; $\"Unknown shape with area {processableShape.CalculateArea():F2}\"\n        };\n    }\n\n    public async Task&lt;double&gt; CalculateAverageAreaAsync(IEnumerable&lt;object?&gt; shapes)\n    {\n        var areas = await Task.WhenAll(\n            shapes\n                .Select(s =&gt; s as IShape)\n                .Where(s =&gt; s != null)\n                .Select(async s =&gt; \n                {\n                    await Task.Delay(100); \/\/ \u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3055\u308c\u305f\u975e\u540c\u671f\u51e6\u7406\n                    return s!.CalculateArea();\n                })\n        );\n\n        return areas.Average();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">as\u6f14\u7b97\u5b50\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9\u3068\u5236\u9650\u4e8b\u9805<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-13\">1. <strong>\u578b\u306e\u4e92\u63db\u6027\u8981\u4ef6<\/strong><\/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=\"\">public class ShapeCompatibilityDemo\n{\n    public void DemonstrateCompatibility()\n    {\n        object circle = new Circle { Radius = 5 };\n\n        \/\/ \u2705 \u6709\u52b9\u306a\u4f7f\u7528\u4f8b\n        var shape = circle as IShape;        \/\/ OK: Circle \u306f IShape \u3092\u5b9f\u88c5\n        var specificCircle = circle as Circle; \/\/ OK: \u540c\u3058\u578b\n\n        \/\/ \u274c \u7121\u52b9\u306a\u4f7f\u7528\u4f8b\n        \/\/ var rectangle = circle as Rectangle; \/\/ OK: \u30b3\u30f3\u30d1\u30a4\u30eb\u306f\u901a\u308b\u304cnull\u304c\u8fd4\u308b\n        \/\/ var number = circle as int;         \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc: \u5024\u578b\u306f\u76f4\u63a5\u4f7f\u7528\u4e0d\u53ef\n        \/\/ var nullable = circle as int?;      \/\/ OK: nullable\u578b\u306f\u4f7f\u7528\u53ef\u80fd\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-14\">2. <strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u914d\u616e<\/strong><\/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=\"\">public class ShapePerformanceOptimizer\n{\n    public void OptimizedProcessing(IEnumerable&lt;object&gt; shapes)\n    {\n        foreach (var shape in shapes)\n        {\n            \/\/ \u540c\u3058\u5909\u63db\u3092\u8907\u6570\u56de\u884c\u308f\u306a\u3044\n            var processableShape = shape as IShape;\n            if (processableShape == null) continue;\n\n            \/\/ \u5909\u63db\u7d50\u679c\u3092\u518d\u5229\u7528\n            Console.WriteLine($\"Type: {processableShape.Type}\");\n            Console.WriteLine($\"Area: {processableShape.CalculateArea()}\");\n\n            \/\/ \u5fc5\u8981\u306a\u5834\u5408\u306e\u307f\u5177\u4f53\u7684\u306a\u578b\u3078\u5909\u63db\n            if (processableShape.Type == \"Circle\")\n            {\n                var circle = processableShape as Circle;\n                if (circle != null)\n                {\n                    Console.WriteLine($\"Radius: {circle.Radius}\");\n                }\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-15\">3. <strong>\u30a8\u30e9\u30fc\u51e6\u7406\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong><\/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=\"\">public class ShapeValidator\n{\n    public class ValidationResult\n    {\n        public bool IsValid { get; set; }\n        public string? ErrorMessage { get; set; }\n    }\n\n    public ValidationResult ValidateShape(object? shape)\n    {\n        if (shape == null)\n        {\n            return new ValidationResult \n            { \n                IsValid = false, \n                ErrorMessage = \"Shape cannot be null\" \n            };\n        }\n\n        var validShape = shape as IShape;\n        if (validShape == null)\n        {\n            return new ValidationResult \n            { \n                IsValid = false, \n                ErrorMessage = \"Object is not a valid shape\" \n            };\n        }\n\n        switch (validShape)\n        {\n            case Circle circle when circle.Radius &lt;= 0:\n                return new ValidationResult \n                { \n                    IsValid = false, \n                    ErrorMessage = \"Circle radius must be positive\" \n                };\n            case Rectangle rectangle when \n                rectangle.Width &lt;= 0 || rectangle.Height &lt;= 0:\n                return new ValidationResult \n                { \n                    IsValid = false, \n                    ErrorMessage = \"Rectangle dimensions must be positive\" \n                };\n            default:\n                return new ValidationResult { IsValid = true };\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u30d1\u30bf\u30fc\u30f3\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u8907\u96d1\u306a\u5b9f\u8df5\u7684\u306a\u30b7\u30ca\u30ea\u30aa\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3055\u3089\u306b\u9ad8\u5ea6\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-16\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3067\u5b66\u3076as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0\u3092\u6d3b\u7528\u3057\u305f\u30af\u30e9\u30b9\u968e\u5c64\u3067\u306e\u578b\u5909\u63db<\/h3>\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 interface IShapeVisitor\n{\n    void Visit(Circle circle);\n    void Visit(Rectangle rectangle);\n    void Visit(Triangle triangle);\n}\n\npublic interface IShapeOperation\n{\n    IShape Execute();\n}\n\npublic class ShapeEditor\n{\n    private readonly Stack&lt;IShape&gt; _undoStack = new();\n    private readonly Stack&lt;IShape&gt; _redoStack = new();\n\n    public void ProcessShapeOperation(object operation)\n    {\n        \/\/ \u64cd\u4f5c\u306e\u7a2e\u985e\u306b\u5fdc\u3058\u305f\u51e6\u7406\n        var shapeOperation = operation as IShapeOperation;\n        if (shapeOperation != null)\n        {\n            var shape = shapeOperation.Execute();\n            _undoStack.Push(shape);\n            _redoStack.Clear();\n        }\n    }\n\n    public void AcceptVisitor(object visitor)\n    {\n        var shapeVisitor = visitor as IShapeVisitor;\n        if (shapeVisitor == null) return;\n\n        foreach (var shape in _undoStack)\n        {\n            switch (shape)\n            {\n                case Circle circle:\n                    shapeVisitor.Visit(circle);\n                    break;\n                case Rectangle rectangle:\n                    shapeVisitor.Visit(rectangle);\n                    break;\n                case Triangle triangle:\n                    shapeVisitor.Visit(triangle);\n                    break;\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u5b9f\u88c5\u6642\u306e\u578b\u30c1\u30a7\u30c3\u30af\u3068\u5909\u63db<\/h3>\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 ModernShapeFactory\n{\n    private readonly Dictionary&lt;string, Func&lt;IShape&gt;&gt; _shapeCreators = new();\n    private readonly ILogger _logger;\n\n    public ModernShapeFactory(object logger)\n    {\n        \/\/ \u30ed\u30ac\u30fc\u306e\u5b89\u5168\u306a\u578b\u5909\u63db\n        _logger = logger as ILogger ?? new ConsoleLogger();\n        InitializeFactory();\n    }\n\n    private void InitializeFactory()\n    {\n        _shapeCreators[\"circle\"] = () =&gt; new Circle { Radius = 1 };\n        _shapeCreators[\"rectangle\"] = () =&gt; new Rectangle { Width = 1, Height = 1 };\n        _shapeCreators[\"triangle\"] = () =&gt; new Triangle { Base = 1, Height = 1 };\n    }\n\n    public IShape? CreateShape(object shapeType)\n    {\n        var typeString = shapeType as string;\n        if (typeString == null)\n        {\n            _logger.Log(\"Invalid shape type provided\");\n            return null;\n        }\n\n        if (_shapeCreators.TryGetValue(typeString.ToLower(), out var creator))\n        {\n            var shape = creator();\n            _logger.Log($\"Created shape of type: {shape.Type}\");\n            return shape;\n        }\n\n        _logger.Log($\"Unknown shape type: {typeString}\");\n        return null;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306b\u304a\u3051\u308bas\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528<\/h3>\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 interface IShapeCommand\n{\n    void Execute();\n}\n\npublic interface IAsyncShapeCommand\n{\n    Task ExecuteAsync();\n}\n\npublic class ShapeCommandProcessor\n{\n    private readonly Queue&lt;object&gt; _commandQueue = new();\n    private readonly IShapeRegistry _registry;\n\n    public ShapeCommandProcessor(IShapeRegistry registry)\n    {\n        _registry = registry;\n    }\n\n    public void EnqueueCommand(object command)\n    {\n        var shapeCommand = command as IShapeCommand;\n        if (shapeCommand != null)\n        {\n            _commandQueue.Enqueue(command);\n        }\n    }\n\n    public async Task ProcessCommandsAsync()\n    {\n        while (_commandQueue.Count &gt; 0)\n        {\n            var command = _commandQueue.Dequeue();\n\n            \/\/ \u975e\u540c\u671f\u30b3\u30de\u30f3\u30c9\u306e\u51e6\u7406\n            var asyncCommand = command as IAsyncShapeCommand;\n            if (asyncCommand != null)\n            {\n                await asyncCommand.ExecuteAsync();\n                continue;\n            }\n\n            \/\/ \u540c\u671f\u30b3\u30de\u30f3\u30c9\u306e\u51e6\u7406\n            var syncCommand = command as IShapeCommand;\n            syncCommand?.Execute();\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u975e\u540c\u671f\u51e6\u7406\u3068as\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b<\/h3>\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 interface IShapeSerializer\n{\n    IShape? Deserialize(string data);\n}\n\npublic class DefaultShapeSerializer : IShapeSerializer\n{\n    public IShape? Deserialize(string data)\n    {\n        \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5b9f\u88c5\n        return null;\n    }\n}\n\npublic class AsyncShapeLoader\n{\n    private readonly IShapeSerializer _serializer;\n\n    public AsyncShapeLoader(object serializer)\n    {\n        _serializer = serializer as IShapeSerializer ?? new DefaultShapeSerializer();\n    }\n\n    public async Task&lt;IShape?&gt; LoadShapeAsync(object shapeData)\n    {\n        try\n        {\n            \/\/ \u30b9\u30c8\u30ea\u30fc\u30e0\u30c7\u30fc\u30bf\u306e\u51e6\u7406\n            var stream = shapeData as Stream;\n            if (stream != null)\n            {\n                using var reader = new StreamReader(stream);\n                var data = await reader.ReadToEndAsync();\n                return await DeserializeShapeAsync(data);\n            }\n\n            \/\/ \u6587\u5b57\u5217\u30c7\u30fc\u30bf\u306e\u51e6\u7406\n            var jsonString = shapeData as string;\n            if (jsonString != null)\n            {\n                return await DeserializeShapeAsync(jsonString);\n            }\n\n            return null;\n        }\n        catch (Exception ex)\n        {\n            Console.WriteLine($\"Error loading shape: {ex.Message}\");\n            return null;\n        }\n    }\n\n    private Task&lt;IShape?&gt; DeserializeShapeAsync(string data)\n    {\n        return Task.Run(() =&gt; _serializer.Deserialize(data));\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3067\u306eas\u6f14\u7b97\u5b50\u306e\u4f7f\u7528<\/h3>\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 record AnalysisResult\n{\n    public bool IsValid { get; init; }\n    public double Area { get; init; }\n    public double Perimeter { get; init; }\n    public string? ShapeType { get; init; }\n}\n\npublic class ShapeAnalyzer\n{\n    public async Task&lt;AnalysisResult&gt; AnalyzeShapeAsync(object shape)\n    {\n        var result = new AnalysisResult();\n\n        \/\/ \u57fa\u672c\u7684\u306a\u5f62\u72b6\u30c1\u30a7\u30c3\u30af\n        var analyzableShape = shape as IShape;\n        if (analyzableShape == null)\n        {\n            return result with { IsValid = false };\n        }\n\n        \/\/ \u8a73\u7d30\u306a\u5206\u6790\n        result = analyzableShape switch\n        {\n            Circle c =&gt; await AnalyzeCircleAsync(c),\n            Rectangle r =&gt; await AnalyzeRectangleAsync(r),\n            Triangle t =&gt; await AnalyzeTriangleAsync(t),\n            _ =&gt; result with { IsValid = false }\n        };\n\n        return result;\n    }\n\n    private async Task&lt;AnalysisResult&gt; AnalyzeCircleAsync(Circle circle)\n    {\n        await Task.Delay(100); \/\/ \u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3055\u308c\u305f\u5206\u6790\n        return new AnalysisResult\n        {\n            IsValid = true,\n            Area = circle.CalculateArea(),\n            Perimeter = 2 * Math.PI * circle.Radius,\n            ShapeType = \"Circle\"\n        };\n    }\n\n    \/\/ \u4ed6\u306e\u5206\u6790\u30e1\u30bd\u30c3\u30c9...\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u8df5\u7684\u306a\u4f8b\u306f\u3001<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u5b9f\u969b\u306e\u958b\u767a\u30b7\u30fc\u30f3\u3067\u3069\u306e\u3088\u3046\u306b\u6d3b\u7528\u3055\u308c\u308b\u304b\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u6700\u9069\u5316\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-22\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30b3\u30fc\u30c9\u54c1\u8cea\u306e\u6700\u9069\u5316<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">as\u30ad\u30fc\u30ef\u30fc\u30c9\u3068is\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u4f7f\u3044\u5206\u3051<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-24\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\u306e\u5b9f\u88c5\u3068\u6e2c\u5b9a<\/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=\"\">#### \u6e2c\u5b9a\u7d50\u679c\u3068\u5206\u6790\nusing System.Diagnostics;\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Running;\n\n[MemoryDiagnoser]\npublic class TypeCheckingBenchmark\n{\n    private readonly object[] _testData;\n    private const int DataSize = 10000;\n\n    public TypeCheckingBenchmark()\n    {\n        _testData = new object[DataSize];\n        for (int i = 0; i &lt; DataSize; i++)\n        {\n            _testData[i] = i % 3 == 0 \n                ? new Circle { Radius = i }\n                : i % 3 == 1 \n                    ? new Rectangle { Width = i, Height = i }\n                    : new Triangle { Base = i, Height = i };\n        }\n    }\n\n    [Benchmark]\n    public void UsingAsKeyword()\n    {\n        double totalArea = 0;\n        foreach (var item in _testData)\n        {\n            var shape = item as IShape;\n            if (shape != null)\n            {\n                totalArea += shape.CalculateArea();\n            }\n        }\n    }\n\n    [Benchmark]\n    public void UsingIsOperator()\n    {\n        double totalArea = 0;\n        foreach (var item in _testData)\n        {\n            if (item is IShape shape)\n            {\n                totalArea += shape.CalculateArea();\n            }\n        }\n    }\n\n    [Benchmark]\n    public void UsingDirectCast()\n    {\n        double totalArea = 0;\n        foreach (var item in _testData)\n        {\n            try\n            {\n                var shape = (IShape)item;\n                totalArea += shape.CalculateArea();\n            }\n            catch (InvalidCastException)\n            {\n                \/\/ \u4f8b\u5916\u3092\u7121\u8996\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-25\">\u6e2c\u5b9a\u7d50\u679c\u3068\u5206\u6790<\/h4>\n\n\n<div id=\"id-1be2ef45-c5ae-4810-aec3-4d4313bd3a3b\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Method<\/th><th>Mean<\/th><th>Error<\/th><th>StdDev<\/th><th>Gen 0<\/th><th>Allocated<\/th><\/tr><\/thead><tbody><tr><td>UsingAsKeyword<\/td><td>15.32 \u03bcs<\/td><td>0.302 \u03bcs<\/td><td>0.282 \u03bcs<\/td><td>\u2013<\/td><td>56 B<\/td><\/tr><tr><td>UsingIsOperator<\/td><td>14.89 \u03bcs<\/td><td>0.297 \u03bcs<\/td><td>0.278 \u03bcs<\/td><td>\u2013<\/td><td>56 B<\/td><\/tr><tr><td>UsingDirectCast<\/td><td>89.45 \u03bcs<\/td><td>1.768 \u03bcs<\/td><td>1.653 \u03bcs<\/td><td>0.9766<\/td><td>2120 B<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-26\">\u578b\u5909\u63db\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\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 ShapeProcessingOptimizer\n{\n    private readonly Dictionary&lt;Type, Func&lt;IShape, double&gt;&gt; _areaCalculators;\n\n    public ShapeProcessingOptimizer()\n    {\n        _areaCalculators = new Dictionary&lt;Type, Func&lt;IShape, double&gt;&gt;\n        {\n            { typeof(Circle), shape =&gt; ((Circle)shape).CalculateArea() },\n            { typeof(Rectangle), shape =&gt; ((Rectangle)shape).CalculateArea() },\n            { typeof(Triangle), shape =&gt; ((Triangle)shape).CalculateArea() }\n        };\n    }\n\n    public void ProcessShapesOptimized(IEnumerable&lt;object&gt; shapes)\n    {\n        \/\/ \u578b\u60c5\u5831\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6d3b\u7528\n        var typeCache = new Dictionary&lt;Type, bool&gt;();\n\n        foreach (var shape in shapes)\n        {\n            var shapeType = shape.GetType();\n\n            \/\/ \u578b\u30c1\u30a7\u30c3\u30af\u306e\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\n            if (!typeCache.TryGetValue(shapeType, out var isValidShape))\n            {\n                isValidShape = shape is IShape;\n                typeCache[shapeType] = isValidShape;\n            }\n\n            if (!isValidShape) continue;\n\n            \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u305f\u578b\u60c5\u5831\u3092\u4f7f\u7528\n            if (_areaCalculators.TryGetValue(shapeType, out var calculator))\n            {\n                var area = calculator((IShape)shape);\n                Console.WriteLine($\"Area: {area}\");\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">\u5358\u4f53\u30c6\u30b9\u30c8\u306b\u304a\u3051\u308bas\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\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 ShapeProcessor\n{\n    public double? ProcessShape(object shape)\n    {\n        var processableShape = shape as IShape;\n        return processableShape?.CalculateArea();\n    }\n}\n\npublic class ShapeProcessorTests\n{\n    [Fact]\n    public void ProcessShape_WithValidShape_CalculatesAreaCorrectly()\n    {\n        \/\/ Arrange\n        var processor = new ShapeProcessor();\n        var mockShape = new Mock&lt;IShape&gt;();\n        mockShape.Setup(s =&gt; s.CalculateArea()).Returns(100.0);\n\n        \/\/ Act\n        var result = processor.ProcessShape(mockShape.Object);\n\n        \/\/ Assert\n        Assert.True(result &gt; 0);\n        mockShape.Verify(s =&gt; s.CalculateArea(), Times.Once);\n    }\n\n    [Fact]\n    public void ProcessShape_WithInvalidShape_ReturnsNull()\n    {\n        \/\/ Arrange\n        var processor = new ShapeProcessor();\n        var invalidShape = new object();\n\n        \/\/ Act\n        var result = processor.ProcessShape(invalidShape);\n\n        \/\/ Assert\n        Assert.Null(result);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-28\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-29\">1. <strong>\u578b\u5909\u63db\u306e\u983b\u5ea6\u6700\u5c0f\u5316<\/strong><\/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=\"\">public class ShapeCache\n{\n    private readonly Dictionary&lt;int, IShape&gt; _shapeCache = new();\n\n    public void ProcessShape(object shape, int id)\n    {\n        \/\/ \u4e00\u5ea6\u306e\u578b\u5909\u63db\u7d50\u679c\u3092\u518d\u5229\u7528\n        var processableShape = shape as IShape;\n        if (processableShape == null) return;\n\n        _shapeCache[id] = processableShape;\n        Console.WriteLine($\"Area: {processableShape.CalculateArea()}\");\n        Console.WriteLine($\"Type: {processableShape.Type}\");\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-30\">2. <strong>\u6761\u4ef6\u5206\u5c90\u306e\u6700\u9069\u5316<\/strong><\/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=\"\">public class ShapeOptimizer\n{\n    public void OptimizeShapeProcessing(IEnumerable&lt;object&gt; shapes)\n    {\n        \/\/ \u578b\u3054\u3068\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u51e6\u7406\n        var groupedShapes = shapes\n            .Select(s =&gt; s as IShape)\n            .Where(s =&gt; s != null)\n            .GroupBy(s =&gt; s!.GetType());\n\n        foreach (var group in groupedShapes)\n        {\n            Console.WriteLine($\"Processing {group.Count()} shapes of type {group.Key.Name}\");\n            foreach (var shape in group)\n            {\n                ProcessShape(shape!);\n            }\n        }\n    }\n\n    private void ProcessShape(IShape shape)\n    {\n        Console.WriteLine($\"Area: {shape.CalculateArea()}\");\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-31\">3. <strong>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316<\/strong><\/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=\"\">public class MemoryEfficientShapeProcessor\n{\n    private readonly ObjectPool&lt;List&lt;IShape&gt;&gt; _listPool;\n\n    public MemoryEfficientShapeProcessor()\n    {\n        _listPool = new ObjectPool&lt;List&lt;IShape&gt;&gt;(\n            () =&gt; new List&lt;IShape&gt;(),\n            list =&gt; list.Clear());\n    }\n\n    public void ProcessShapes(IEnumerable&lt;object&gt; shapes)\n    {\n        var validShapes = _listPool.Get();\n        try\n        {\n            foreach (var shape in shapes)\n            {\n                var validShape = shape as IShape;\n                if (validShape != null)\n                {\n                    validShapes.Add(validShape);\n                }\n            }\n\n            \/\/ \u6709\u52b9\u306a\u5f62\u72b6\u306e\u4e00\u62ec\u51e6\u7406\n            ProcessValidShapes(validShapes);\n        }\n        finally\n        {\n            _listPool.Return(validShapes);\n        }\n    }\n\n    private void ProcessValidShapes(List&lt;IShape&gt; shapes)\n    {\n        foreach (var shape in shapes)\n        {\n            Console.WriteLine($\"Processing {shape.Type}\");\n        }\n    }\n}\n\npublic class ObjectPool&lt;T&gt;\n{\n    private readonly Func&lt;T&gt; _factory;\n    private readonly Action&lt;T&gt; _reset;\n    private readonly ConcurrentBag&lt;T&gt; _objects = new();\n\n    public ObjectPool(Func&lt;T&gt; factory, Action&lt;T&gt; reset)\n    {\n        _factory = factory;\n        _reset = reset;\n    }\n\n    public T Get() =&gt; _objects.TryTake(out var item) ? item : _factory();\n\n    public void Return(T item)\n    {\n        _reset(item);\n        _objects.Add(item);\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u54c1\u8cea\u306e\u4e21\u9762\u3067\u512a\u308c\u305f\u30b3\u30fc\u30c9\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<br>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u304f\u3042\u308b\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3068\u56de\u907f\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-32\">\u3088\u304f\u3042\u308b\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3068\u56de\u907f\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-33\">\u4f8b\u5916\u51e6\u7406\u306e\u4ee3\u7528\u3068\u3057\u3066\u306e\u8aa4\u3063\u305f\u4f7f\u7528<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-34\">\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f31: \u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306e\u5236\u5fa1\u3068\u3057\u3066\u306e\u4f7f\u7528<\/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=\"\">public class ShapeProcessorAntiPattern\n{\n    \/\/ \u274c \u60aa\u3044\u4f8b\uff1a\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306e\u5236\u5fa1\u306bas\u3092\u4f7f\u7528\n    public void ProcessShapeBadly(object shape)\n    {\n        var circle = shape as Circle;\n        if (circle != null)\n        {\n            \/\/ \u51e6\u7406\n        }\n        else\n        {\n            var rectangle = shape as Rectangle;\n            if (rectangle != null)\n            {\n                \/\/ \u51e6\u7406\n            }\n            else\n            {\n                \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u51e6\u7406\n            }\n        }\n    }\n\n    \/\/ \u2705 \u826f\u3044\u4f8b\uff1a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3092\u4f7f\u7528\u3057\u305f\u660e\u78ba\u306a\u5236\u5fa1\u30d5\u30ed\u30fc\n    public void ProcessShapeCorrectly(object shape)\n    {\n        switch (shape)\n        {\n            case Circle circle:\n                ProcessCircle(circle);\n                break;\n            case Rectangle rectangle:\n                ProcessRectangle(rectangle);\n                break;\n            default:\n                throw new ArgumentException(\"Unsupported shape type\", nameof(shape));\n        }\n    }\n\n    private void ProcessCircle(Circle circle) { }\n    private void ProcessRectangle(Rectangle rectangle) { }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-35\">\u4e0d\u5fc5\u8981\u306a\u578b\u5909\u63db\u306e\u9023\u9396\u3092\u907f\u3051\u308b<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-36\">\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f32: \u91cd\u8907\u3059\u308b\u578b\u30c1\u30a7\u30c3\u30af<\/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=\"\">public class ShapeValidatorAntiPattern\n{\n    \/\/ \u274c \u60aa\u3044\u4f8b\uff1a\u91cd\u8907\u3059\u308b\u578b\u30c1\u30a7\u30c3\u30af\u3068\u5909\u63db\n    public void ValidateShapeBadly(object shape)\n    {\n        var baseShape = shape as IShape;\n        if (baseShape != null)\n        {\n            var area = baseShape.CalculateArea();\n\n            \/\/ \u4e0d\u5fc5\u8981\u306a\u8ffd\u52a0\u306e\u578b\u30c1\u30a7\u30c3\u30af\u3068\u5909\u63db\n            var circle = baseShape as Circle;\n            if (circle != null)\n            {\n                ValidateCircle(circle);\n            }\n            else\n            {\n                var rectangle = baseShape as Rectangle;\n                if (rectangle != null)\n                {\n                    ValidateRectangle(rectangle);\n                }\n            }\n        }\n    }\n\n    \/\/ \u2705 \u826f\u3044\u4f8b\uff1a\u52b9\u7387\u7684\u306a\u578b\u30c1\u30a7\u30c3\u30af\u3068\u51e6\u7406\n    public void ValidateShapeCorrectly(object shape)\n    {\n        if (shape is not IShape validShape)\n        {\n            throw new ArgumentException(\"Invalid shape type\", nameof(shape));\n        }\n\n        switch (validShape)\n        {\n            case Circle circle:\n                ValidateCircle(circle);\n                break;\n            case Rectangle rectangle:\n                ValidateRectangle(rectangle);\n                break;\n            default:\n                ValidateGenericShape(validShape);\n                break;\n        }\n    }\n\n    private void ValidateCircle(Circle circle) { }\n    private void ValidateRectangle(Rectangle rectangle) { }\n    private void ValidateGenericShape(IShape shape) { }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-37\">null\u53c2\u7167\u306e\u5b89\u5168\u306a\u51e6\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-38\">\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f33: \u4e0d\u9069\u5207\u306anull\u51e6\u7406<\/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=\"\">public class ShapeRegistryAntiPattern\n{\n    \/\/ \u274c \u60aa\u3044\u4f8b\uff1a\u4e0d\u9069\u5207\u306anull\u51e6\u7406\n    public class UnsafeShapeRegistry\n    {\n        private readonly Dictionary&lt;string, IShape&gt; _shapes = new();\n\n        public void RegisterShape(string key, object shape)\n        {\n            var registrableShape = shape as IShape;\n            _shapes[key] = registrableShape;  \/\/ \u5371\u967a\uff1anull\u304c\u683c\u7d0d\u3055\u308c\u308b\u53ef\u80fd\u6027\n        }\n\n        public double GetArea(string key)\n        {\n            return _shapes[key].CalculateArea();  \/\/ \u5371\u967a\uff1aNullReferenceException\n        }\n    }\n\n    \/\/ \u2705 \u826f\u3044\u4f8b\uff1anull\u5b89\u5168\u306a\u5b9f\u88c5\n    public class SafeShapeRegistry\n    {\n        private readonly Dictionary&lt;string, IShape&gt; _shapes = new();\n\n        public Result RegisterShape(string key, object shape)\n        {\n            if (string.IsNullOrEmpty(key))\n            {\n                return Result.Failure(\"Key cannot be null or empty\");\n            }\n\n            var registrableShape = shape as IShape;\n            if (registrableShape == null)\n            {\n                return Result.Failure(\"Invalid shape type\");\n            }\n\n            _shapes[key] = registrableShape;\n            return Result.Success();\n        }\n\n        public Result&lt;double&gt; GetArea(string key)\n        {\n            if (!_shapes.TryGetValue(key, out var shape))\n            {\n                return Result&lt;double&gt;.Failure($\"Shape not found for key: {key}\");\n            }\n\n            return Result&lt;double&gt;.Success(shape.CalculateArea());\n        }\n    }\n\n    public class Result\n    {\n        public bool IsSuccess { get; }\n        public string? Error { get; }\n\n        protected Result(bool isSuccess, string? error = null)\n        {\n            IsSuccess = isSuccess;\n            Error = error;\n        }\n\n        public static Result Success() =&gt; new(true);\n        public static Result Failure(string error) =&gt; new(false, error);\n    }\n\n    public class Result&lt;T&gt; : Result\n    {\n        public T? Value { get; }\n\n        protected Result(T value) : base(true) =&gt; Value = value;\n        protected Result(string error) : base(false, error) =&gt; Value = default;\n\n        public static Result&lt;T&gt; Success(T value) =&gt; new(value);\n        public static new Result&lt;T&gt; Failure(string error) =&gt; new(error);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-39\">\u6539\u5584\u306e\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-40\">1. <strong>\u578b\u30c1\u30a7\u30c3\u30af\u306e\u96c6\u4e2d\u5316<\/strong><\/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=\"\">public class ShapeValidator\n{\n    private readonly HashSet&lt;Type&gt; _validShapeTypes = new()\n    {\n        typeof(Circle),\n        typeof(Rectangle),\n        typeof(Triangle)\n    };\n\n    public bool IsValidShape(object shape)\n    {\n        if (shape == null) return false;\n\n        var shapeType = shape.GetType();\n        return _validShapeTypes.Contains(shapeType) &amp;&amp; shape is IShape;\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-41\">2. <strong>Factory Pattern\u306e\u6d3b\u7528<\/strong><\/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=\"\">public class ShapeFactory\n{\n    private readonly Dictionary&lt;string, Func&lt;IShape&gt;&gt; _shapeCreators = new()\n    {\n        [\"circle\"] = () =&gt; new Circle { Radius = 1 },\n        [\"rectangle\"] = () =&gt; new Rectangle { Width = 1, Height = 1 },\n        [\"triangle\"] = () =&gt; new Triangle { Base = 1, Height = 1 }\n    };\n\n    public Result&lt;IShape&gt; CreateShape(string shapeType)\n    {\n        if (!_shapeCreators.TryGetValue(shapeType.ToLower(), out var creator))\n        {\n            return Result&lt;IShape&gt;.Failure($\"Unknown shape type: {shapeType}\");\n        }\n\n        return Result&lt;IShape&gt;.Success(creator());\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3092\u8a8d\u8b58\u3057\u3001\u9069\u5207\u306a\u5bfe\u51e6\u6cd5\u3092\u5b9f\u8df5\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u4fdd\u5b88\u6027\u304c\u9ad8\u304f\u3001\u30d0\u30b0\u306e\u5c11\u306a\u3044\u30b3\u30fc\u30c9\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-42\">C# 12\u3067\u306e\u65b0\u6a5f\u80fd\u3068\u5c06\u6765\u306e\u5c55\u671b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-43\">\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306e\u578b\u5909\u63db\u6a5f\u80fd\u306e\u9032\u5316<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-44\">Collection Expressions\u3068\u306e\u7d71\u5408<\/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=\"\">public class ModernShapeProcessor\n{\n    \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5f0f\u3092\u4f7f\u7528\u3057\u305f\u5f62\u72b6\u51e6\u7406\n    public void ProcessShapes()\n    {\n        \/\/ \u65b0\u3057\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u69cb\u6587\n        object shapes = [\n            new Circle { Radius = 5 },\n            new Rectangle { Width = 3, Height = 4 },\n            new Triangle { Base = 6, Height = 8 }\n        ];\n\n        if (shapes is IShape[] shapeArray)\n        {\n            foreach (var shape in shapeArray)\n            {\n                Console.WriteLine($\"Area: {shape.CalculateArea()}\");\n            }\n        }\n    }\n\n    \/\/ \u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\n    public class ShapeAnalyzer(ILogger logger)\n    {\n        public void AnalyzeShape(object shape)\n        {\n            var analyzableShape = shape as IShape;\n            if (analyzableShape is null)\n            {\n                logger.Log(\"Invalid shape provided\");\n                return;\n            }\n\n            logger.Log($\"Analyzing shape of type: {analyzableShape.Type}\");\n            logger.Log($\"Area: {analyzableShape.CalculateArea()}\");\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-45\">\u65b0\u3057\u3044\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u6a5f\u80fd<\/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=\"\">public class EnhancedShapeProcessor\n{\n    public async Task ProcessShapeAsync(object shape)\n    {\n        var result = shape switch\n        {\n            \/\/ \u62e1\u5f35\u3055\u308c\u305f\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\n            Circle { Radius: &gt; 0 } circle =&gt; \n                await ProcessCircleAsync(circle),\n\n            Rectangle { Width: &gt; 0, Height: &gt; 0 } rectangle =&gt; \n                await ProcessRectangleAsync(rectangle),\n\n            Triangle { Base: &gt; 0, Height: &gt; 0 } triangle =&gt; \n                await ProcessTriangleAsync(triangle),\n\n            IShape s =&gt; \n                await ProcessGenericShapeAsync(s),\n\n            \/\/ \u30ea\u30b9\u30c8\u30d1\u30bf\u30fc\u30f3\u306e\u6d3b\u7528\n            IEnumerable&lt;object&gt; list when list is [IShape first, .., IShape last] =&gt;\n                await ProcessShapeCollectionAsync(first, last),\n\n            _ =&gt; Task.FromResult(new ShapeProcessingResult(\"Invalid shape type\"))\n        };\n    }\n\n    private record ShapeProcessingResult(string Message);\n\n    private Task&lt;ShapeProcessingResult&gt; ProcessCircleAsync(Circle circle) =&gt;\n        Task.FromResult(new ShapeProcessingResult($\"Processed circle with area {circle.CalculateArea()}\"));\n\n    \/\/ \u4ed6\u306e\u51e6\u7406\u30e1\u30bd\u30c3\u30c9...x\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-46\">\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306e\u767a\u5c55\u3068\u4eca\u5f8c\u306e\u53ef\u80fd\u6027<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-47\">\u578b\u30b7\u30b9\u30c6\u30e0\u306e\u9032\u5316<\/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=\"\">public class FutureShapeProcessor\n{\n    \/\/ \u5c06\u6765\u7684\u306b\u671f\u5f85\u3055\u308c\u308b\u6a5f\u80fd\u306e\u4f8b\n    public void ProcessShape&lt;T&gt;(object shape) where T : IShape\n    {\n        \/\/ \u4eee\u60f3\u7684\u306a\u69cb\u6587\u4f8b\uff1a\u3088\u308a\u76f4\u611f\u7684\u306a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\n        if (shape is T typed and (Circle or Rectangle))\n        {\n            Console.WriteLine($\"Processing specific shape: {typed.Type}\");\n        }\n    }\n\n    \/\/ \u30a4\u30f3\u30bf\u30fc\u30bb\u30af\u30b7\u30e7\u30f3\u578b\u306e\u6d3b\u7528\u4f8b\uff08\u4eee\u60f3\u7684\u306a\u69cb\u6587\uff09\n    public interface IDrawable\n    {\n        void Draw();\n    }\n\n    public void ProcessDrawableShape(object shape)\n    {\n        \/\/ \u5c06\u6765\u7684\u306a\u69cb\u6587\u4f8b\n        if (shape is (IShape &amp; IDrawable) drawableShape)\n        {\n            drawableShape.Draw();\n            Console.WriteLine($\"Area: {drawableShape.CalculateArea()}\");\n        }\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-48\">\u578b\u5b89\u5168\u6027\u306e\u5f37\u5316<\/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=\"\">public class SafeShapeProcessor\n{\n    \/\/ Null\u5b89\u5168\u6027\u306e\u5f37\u5316\n    public void ProcessShapeSafely(object? shape)\n    {\n        \/\/ \u3088\u308a\u5f37\u529b\u306anull\u691c\u67fb\u3068\u578b\u30c1\u30a7\u30c3\u30af\n        if (shape is not null and IShape processableShape)\n        {\n            ProcessValidShape(processableShape);\n        }\n    }\n\n    \/\/ \u578b\u5236\u7d04\u306e\u5f37\u5316\n    public void ProcessShapeCollection&lt;T&gt;(IEnumerable&lt;T&gt; shapes) \n        where T : class, IShape\n    {\n        foreach (var shape in shapes)\n        {\n            \/\/ \u578b\u5b89\u5168\u306a\u51e6\u7406\n            Console.WriteLine($\"Processing {shape.Type}\");\n        }\n    }\n\n    private void ProcessValidShape(IShape shape)\n    {\n        Console.WriteLine($\"Area: {shape.CalculateArea()}\");\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-49\">\u5c06\u6765\u7684\u306a\u5c55\u671b<\/h4>\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>\u578b\u30b7\u30b9\u30c6\u30e0\u306e\u62e1\u5f35<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>\u3088\u308a\u67d4\u8edf\u306a\u578b\u306e\u5408\u6210<\/li>\n\n\n\n<li>\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306e\u66f4\u306a\u308b\u5f37\u5316<\/li>\n\n\n\n<li>\u578b\u63a8\u8ad6\u306e\u6539\u5584<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>\u578b\u30c1\u30a7\u30c3\u30af\u306e\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u6700\u9069\u5316<\/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\n\n\n<li><strong>\u958b\u767a\u8005\u30a8\u30af\u30b9\u30da\u30ea\u30a8\u30f3\u30b9\u306e\u5411\u4e0a<\/strong>\n<ul class=\"wp-block-list is-style-sango-list-simple\">\n<li>\u3088\u308a\u76f4\u611f\u7684\u306a\u578b\u5909\u63db\u69cb\u6587<\/li>\n\n\n\n<li>\u5f37\u5316\u3055\u308c\u305f\u9759\u7684\u578b\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li>\u3088\u308a\u826f\u3044\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div>\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=\"\">\/\/ \u5c06\u6765\u7684\u306a\u6a5f\u80fd\u306e\u4f8b\u793a\npublic class FutureFeatures\n{\n    \/\/ \u578b\u306e\u5408\u6210\n    public interface IMetrics : IShape\n    {\n        double CalculatePerimeter();\n    }\n\n    \/\/ \u62e1\u5f35\u3055\u308c\u305f\u578b\u30c1\u30a7\u30c3\u30af\n    public void ProcessExtendedShape(object shape)\n    {\n        if (shape is IShape with IMetrics metrics)\n        {\n            Console.WriteLine($\"Area: {metrics.CalculateArea()}\");\n            Console.WriteLine($\"Perimeter: {metrics.CalculatePerimeter()}\");\n        }\n    }\n\n    \/\/ \u9ad8\u5ea6\u306a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\n    public void ProcessShapeCollection(object[] shapes)\n    {\n        if (shapes is [IShape first, .., IShape last] collection)\n        {\n            Console.WriteLine($\"First shape: {first.Type}\");\n            Console.WriteLine($\"Last shape: {last.Type}\");\n            Console.WriteLine($\"Total shapes: {collection.Length}\");\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u9032\u5316\u306b\u3088\u308a\u3001C#\u306e\u578b\u30b7\u30b9\u30c6\u30e0\u306f\u3088\u308a\u8868\u73fe\u529b\u8c4a\u304b\u3067\u5b89\u5168\u306a\u3082\u306e\u3068\u306a\u308a\u3001\u958b\u767a\u8005\u306e\u751f\u7523\u6027\u306f\u66f4\u306b\u5411\u4e0a\u3059\u308b\u3053\u3068\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002<br>\u7279\u306b<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u578b\u5909\u63db\u306e\u6a5f\u80fd\u306f\u3001\u65b0\u3057\u3044\u8a00\u8a9e\u6a5f\u80fd\u3068\u306e\u7d71\u5408\u306b\u3088\u3063\u3066\u3088\u308a\u5f37\u529b\u306b\u306a\u3063\u3066\u3044\u304f\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-50\"><code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u307e\u3068\u3081<\/h2>\n\n\n\n<p><code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306f\u3001\u5358\u306a\u308b\u578b\u5909\u63db\u306e\u624b\u6bb5\u4ee5\u4e0a\u306e\u4fa1\u5024\u3092\u6301\u3064\u30c4\u30fc\u30eb\u3067\u3059\u3002\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u5b89\u5168\u6027\u3001\u53ef\u8aad\u6027\u3001\u305d\u3057\u3066\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u6700\u65b0\u306eC#\u6a5f\u80fd\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u3088\u308a\u3001\u305d\u306e\u53ef\u80fd\u6027\u306f\u3055\u3089\u306b\u5e83\u304c\u3063\u3066\u3044\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<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u5168\u6027\u3068\u52b9\u7387\u6027<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u306a\u3044\u5b89\u5168\u306a\u578b\u5909\u63db<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u9069\u5207\u306a\u4f7f\u7528\u65b9\u6cd5<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5b9f\u8df5\u7684\u306a\u6d3b\u7528\u6cd5<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3068\u306e\u7d71\u5408<\/li>\n\n\n\n<li>\u975e\u540c\u671f\u51e6\u7406\u3067\u306e\u52b9\u679c\u7684\u306a\u4f7f\u7528<\/li>\n\n\n\n<li>\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3067\u306e\u6d3b\u7528<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6700\u9069\u5316\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u578b\u5909\u63db\u306e\u983b\u5ea6\u6700\u5c0f\u5316<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30b3\u30fc\u30c9\u54c1\u8cea\u306e\u5411\u4e0a<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6ce8\u610f\u70b9\u3068\u56de\u907f\u3059\u3079\u304d\u4e8b\u9805<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u9069\u5207\u306anull\u51e6\u7406\u306e\u9632\u6b62<\/li>\n\n\n\n<li>\u91cd\u8907\u3059\u308b\u578b\u30c1\u30a7\u30c3\u30af\u306e\u56de\u907f<\/li>\n\n\n\n<li>\u4f8b\u5916\u51e6\u7406\u306e\u9069\u5207\u306a\u4f7f\u7528<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5c06\u6765\u3078\u306e\u5bfe\u5fdc<\/strong>\n<ul class=\"wp-block-list\">\n<li>C# 12\u306e\u65b0\u6a5f\u80fd\u3068\u306e\u7d71\u5408<\/li>\n\n\n\n<li>\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u578b\u30b7\u30b9\u30c6\u30e0\u306e\u9032\u5316\u3078\u306e\u6e96\u5099<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div><\/div>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u62bc\u3055\u3048\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u679c\u7684\u306a<code>as<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528\u304c\u53ef\u80fd\u3068\u306a\u308a\u3001\u9ad8\u54c1\u8cea\u306aC#\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\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":2841,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,61],"tags":[],"class_list":{"0":"post-1646","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\/1646","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=1646"}],"version-history":[{"count":8,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/1646\/revisions"}],"predecessor-version":[{"id":2842,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/1646\/revisions\/2842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/media\/2841"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}