{"id":3395,"date":"2023-05-29T00:17:41","date_gmt":"2023-05-28T16:17:41","guid":{"rendered":"https:\/\/lonelinerd.com\/?p=3395"},"modified":"2023-06-08T00:44:59","modified_gmt":"2023-06-07T16:44:59","slug":"extension-method","status":"publish","type":"post","link":"https:\/\/lonelinerd.com\/index.php\/2023\/05\/29\/extension-method\/","title":{"rendered":"C#\u7b46\u8a18 \u2013 \u64f4\u5c55\u65b9\u6cd5"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3395\" class=\"elementor elementor-3395\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c8d6831 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c8d6831\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7f9059a\" data-id=\"7f9059a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b1b56d9 elementor-widget elementor-widget-text-editor\" data-id=\"b1b56d9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<h5><strong>\u64f4\u5c55\u65b9\u6cd5<\/strong><\/h5><ul data-mark=\"-\"><li><p>\u64f4\u5c55\u65b9\u6cd5\u5141\u8a31\u5b9a\u7fa9\u4e00\u500b\u975c\u614b\u65b9\u6cd5\uff0c\u4f46\u662f\u7528\u5be6\u4f8b\u65b9\u6cd5\u7684\u8a9e\u6cd5\u4f86\u8abf\u7528\uff0c\u4f7f\u4ee3\u78bc\u7684\u884c\u70ba\u9806\u5e8f\u770b\u4e0a\u53bb\u66f4\u5408\u7406<\/p><\/li><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">public static int IndexOf(this StringBuilder sb, char value)<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0for (int i = 0; i &lt; sb.Length; i++)<\/span><br \/><span role=\"presentation\"> \u00a0  {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0if(sb[i] == value)<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0  {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0return i;<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0  }<\/span><br \/><span role=\"presentation\"> \u00a0  }<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0return -1;<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><li><p>\u73fe\u5728\uff0c\u5982\u679cC#\u7de8\u8b6f\u5668\u770b\u5230\u4ee5\u4e0b\u4ee3\u78bc\uff1a<\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">StringBuilder sb = new StringBuilder();<\/span><br \/><span role=\"presentation\">int idx = sb.IndexOf('a');<\/span><\/pre><\/li><li><p>C#\u7de8\u8b6f\u5668<span spellcheck=\"false\"><span style=\"color: red;\">\u9996\u5148\u6703\u6aa2\u67e5StringBuilder\u985e\u6216\u5176\u6240\u6709\u57fa\u985e\u6709\u6c92\u6709\u63d0\u4f9b\u5c0d\u61c9\u7684\u5be6\u4f8b\u65b9\u6cd5<\/span><\/span><\/p><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u5982\u679c\u6c92\u6709\uff0c\u5c31\u6aa2\u67e5\u6709\u6c92\u6709\u975c\u614b\u985e\u5b9a\u7fa9\u4e86\u5c0d\u61c9\u7684\u975c\u614b\u65b9\u6cd5\uff0c\u800c\u4e14\u65b9\u6cd5\u7b2c\u4e00\u500b\u53c3\u6578\u985e\u578b\u70baStringBuilder\uff0c\u4e26\u4f7f\u7528\u4e86this\u6a19\u793a<\/span><\/span><\/p><\/li><\/ul><\/li><li><p>\u898f\u5247<\/p><ul data-mark=\"-\"><li><p>C#<span spellcheck=\"false\"><span style=\"color: red;\">\u53ea\u652f\u6301\u64f4\u5c55\u300c\u65b9\u6cd5\u300d<\/span><\/span><\/p><\/li><li><p>\u64f4\u5c55\u65b9\u6cd5\u5fc5\u9808<span spellcheck=\"false\"><span style=\"color: red;\">\u5728\u975e\u6cdb\u578b\u975c\u614b\u985e\u4e2d\u8072\u660e<\/span><\/span><\/p><ul data-mark=\"-\"><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u81f3\u5c11\u8981\u6709\u4e00\u500b\u53c3\u6578\uff0c\u800c\u4e14\u53ea\u6709\u7b2c\u4e00\u500b\u53c3\u6578\u80fd\u7528this\u95dc\u9375\u5b57\u6a19\u8a18<\/span><\/span><\/p><ul data-mark=\"-\"><li><p><span style=\"font-style: inherit; font-weight: inherit;\">\u7b2c\u4e00\u500b\u53c3\u6578\u4e0d\u80fd\u6709\u5176\u4ed6\u4fee\u98fe\u7b26\uff08\u5982out\/ref\uff09<\/span><\/p><\/li><li><p><span style=\"font-style: inherit; font-weight: inherit;\">\u7b2c\u4e00\u500b\u53c3\u6578\u985e\u578b\uff08<\/span><span style=\"font-style: inherit; font-weight: inherit;\">\u64f4\u5c55\u985e\u578b\uff09<\/span><span style=\"font-style: inherit; font-weight: inherit;\">\u4e0d\u80fd\u662f\u6307\u91dd\u985e\u578b<\/span><\/p><\/li><\/ul><\/li><li><p>\u8a72\u975c\u614b\u985e\u4e0d\u80fd\u5d4c\u5957\u5728\u5176\u4ed6\u985e\u88e1\u9762\uff0c<span spellcheck=\"false\"><span style=\"color: red;\">\u5fc5\u9808\u662f\u300c\u9802\u7d1a\u975c\u614b\u985e\u300d<\/span><\/span><\/p><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">C#\u7de8\u8b6f\u5668\u67e5\u627e\u975c\u614b\u985e\u6642\uff1a<\/span><\/span><\/p><ul data-mark=\"-\"><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u6aa2\u67e5\u6587\u4ef6\u4f5c\u7528\u57df\u4e2d\u6240\u6709\u975c\u614b\u985e\uff0c\u6383\u7784\u5b83\u5011\u7684\u6240\u6709\u975c\u614b\u65b9\u6cd5\u4f86\u627e\u5339\u914d\u9805\uff0c\u53ef\u4ee5\u4e8b\u5148\u4f7f\u7528using\u5c0e\u5165\u547d\u540d\u7a7a\u9593\uff0c\u63d0\u5347\u67e5\u627e\u6548\u7387<\/span><\/span><\/p><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u5982\u679c\u6aa2\u6e2c\u5230\u591a\u500b\u540c\u6a23\u5b9a\u6a23\u7684\u64f4\u5c55\u65b9\u6cd5\uff0c\u5c31\u9700\u8981\u986f\u5f0f\u6307\u5b9a\u975c\u614b\u985e\u7684\u540d\u7a31<\/span><\/span><\/p><\/li><li><p>\u5982\u679c\u5b58\u5728\u9069\u7576\u7684\u5be6\u4f8b\u65b9\u6cd5\uff0c\u5247<span spellcheck=\"false\">\u5be6\u4f8b\u65b9\u6cd5\u80af\u5b9a\u6703\u5148\u65bc\u64f4\u5c55\u65b9\u6cd5\u4f7f\u7528\uff0c\u4e26\u4e0d\u6703\u88ab\u7de8\u8b6f\u5668\u8b66\u544a<\/span><\/p><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u64f4\u5c55\u4e00\u500b\u985e\u578b\u7684\u65b9\u6cd5\u6642\uff0c\u540c\u6642\u4e5f\u64f4\u5c55\u4e86\u6d3e\u751f\u985e<\/span><\/span><\/p><ul data-mark=\"-\"><li><p>\u4e0d\u8981\u5c07System.Object\u4f5c\u70ba\u64f4\u5c55\u65b9\u6cd5\u7684\u7b2c\u4e00\u500b\u53c3\u6578<\/p><\/li><\/ul><\/li><\/ul><\/li><\/ul><ul data-mark=\"-\"><li><p>\u64f4\u5c55\u65b9\u6cd5\u96d6\u7136\u662f\u901a\u904e\u5be6\u4f8b\u65b9\u6cd5\u7684\u8a9e\u6cd5\u4f86\u8abf\u7528\uff0c\u4f46<span spellcheck=\"false\"><span style=\"color: red;\">\u5be6\u969b\u4e0a\u9084\u662f\u4e00\u500b\u975c\u614b\u65b9\u6cd5\uff0c\u6240\u4ee5IL\u751f\u6210\u7684\u8abf\u7528\u4ee3\u78bc\u662fcall<\/span><\/span>\u800c\u4e0d\u662fcallvirt<\/p><ul data-mark=\"-\"><li><p>\u56e0\u6b64\uff0c<span spellcheck=\"false\"><span style=\"color: red;\">CLR\u4e5f\u4e0d\u6703\u751f\u6210\u5c0d\u8abf\u7528\u65b9\u6cd5\u7684\u8868\u9054\u5f0f\u7684\u503c\u9032\u884cnull\u6aa2\u67e5\u7684\u4ee3\u78bc<\/span><\/span><\/p><ul data-mark=\"-\"><li>\u5728C#\u4e2d\uff0c<span spellcheck=\"false\">\u4e0d\u80fd\u5728\u7a7a\u5f15\u7528\u4e0a\u8abf\u7528\u5be6\u4f8b\u65b9\u6cd5\uff0c\u4f46\u53ef\u4ee5\u8abf\u7528\u64f4\u5c55\u65b9\u6cd5<\/span><\/li><\/ul><\/li><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">StringBuilder sb = null;<\/span><br \/><span role=\"presentation\">sb.IndexOf('c'); \/\/throw exception inside IndexOf<\/span><br \/><span role=\"presentation\">sb.Replace('.', '!'); \/\/throw exception in this command line<\/span><\/pre><\/li><li><pre lang=\"IL\" spellcheck=\"false\"><span role=\"presentation\">.method private hidebysig static void  Main(string[] args) cil managed<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\">  .entrypoint<\/span><br \/><span role=\"presentation\">  \/\/ \u7a0b\u5f0f\u78bc\u5927\u5c0f \u00a0 \u00a0 \u00a0 48 (0x30)<\/span><br \/><span role=\"presentation\">  .maxstack  3<\/span><br \/><span role=\"presentation\">  .locals init (class [System.Runtime]System.Text.StringBuilder V_0,<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 class [System.Runtime]System.Action V_1)<\/span><br \/><span role=\"presentation\">  IL_0000:  nop<\/span><br \/><span role=\"presentation\">  IL_0001:  ldnull<\/span><br \/><span role=\"presentation\">  IL_0002:  stloc.0<\/span><br \/><span role=\"presentation\">  IL_0003:  ldloc.0<\/span><br \/><span role=\"presentation\">  IL_0004:  ldc.i4.s \u00a0 99<\/span><br \/><span role=\"presentation\">  IL_0006:  call \u00a0 \u00a0 \u00a0 int32 CLR_Ch8.Extensions::IndexOf(class [System.Runtime]System.Text.StringBuilder,<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 char)<\/span><br \/><span role=\"presentation\">  IL_000b:  pop<\/span><br \/><span role=\"presentation\">  IL_000c:  ldloc.0<\/span><br \/><span role=\"presentation\">  IL_000d:  ldc.i4.s \u00a0 46<\/span><br \/><span role=\"presentation\">  IL_000f:  ldc.i4.s \u00a0 33<\/span><br \/><span role=\"presentation\">  IL_0011:  callvirt \u00a0 instance class [System.Runtime]System.Text.StringBuilder [System.Runtime]System.Text.StringBuilder::Replace(char,<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 char)<\/span><br \/><span role=\"presentation\">  IL_0016:  pop<\/span><br \/><span role=\"presentation\">} \/\/ end of method Program::Main<\/span><\/pre><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u63a5\u53e3\u5b9a\u7fa9\u7684\u64f4\u5c55\u65b9\u6cd5<\/span><\/span><\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">\/\/Extension on Interface<\/span><br \/><span role=\"presentation\">public static void ShowItems&lt;T&gt;(this IEnumerable&lt;T&gt; collection)<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0foreach (var item in collection)<\/span><br \/><span role=\"presentation\"> \u00a0  {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0Console.WriteLine(item);<\/span><br \/><span role=\"presentation\"> \u00a0  }<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u59d4\u6258\u5b9a\u7fa9\u7684\u64f4\u5c55\u65b9\u6cd5<\/span><\/span><\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">\/\/Extension on Delegate<\/span><br \/><span role=\"presentation\">public static void InvokeAndCatch&lt;TException&gt;(this Action&lt;Object&gt; d, Object o)<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0where TException : Exception<\/span><br \/><span role=\"presentation\"> \u00a0  {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0try { d(o); }<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0catch (TException) { }<\/span><br \/><span role=\"presentation\"> \u00a0  }<\/span><\/pre><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u59d4\u6258\u4e5f\u53ef\u4ee5\u6307\u5411\u4e00\u500b\u64f4\u5c55\u65b9\u6cd5<\/span><\/span><\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">Action a = \"Jeff\".ShowItems;<\/span><br \/><span role=\"presentation\">a();<\/span><\/pre><\/li><\/ul><\/li><\/ul><\/li><\/ul><h5><strong><span spellcheck=\"false\"><span style=\"color: red;\">ExtensionAttribute<\/span><\/span><\/strong><\/h5><ul data-mark=\"-\"><li><p><span spellcheck=\"false\">\u67e5\u627e\u64f4\u5c55\u65b9\u6cd5\u6642\uff0cC#\u7de8\u8b6f\u5668\u6703\u6aa2\u67e5\u5c0e\u5165\u7684\u6240\u6709\u547d\u540d\u7a7a\u9593\u548c\u7576\u524d\u547d\u540d\u7a7a\u9593\u4e2d\u7684\u6240\u6709\u64f4\u5c55\u65b9\u6cd5\uff0c\u4e26\u5339\u914d\u90a3\u4e9b\u5f9e\u8868\u9054\u5f0f\u985e\u578b\u5230\u64f4\u5c55\u985e\u578b\u5b58\u5728\u96b1\u5f0f\u8f49\u63db\u7684\u64f4\u5c55\u65b9\u6cd5\uff0c\u56e0\u6b64<\/span><span style=\"font-size: 16px;\">\u7de8\u8b6f\u5668\u5fc5\u9808\u80fd\u5340\u5206\u64f4\u5c55\u65b9\u6cd5\u8207\u67d0\u975c\u614b\u985e\u4e2d\u6070\u597d\u5177\u6709\u5408\u9069\u7c3d\u540d\u7684\u5176\u4ed6\u65b9\u6cd5<\/span><\/p><ul data-mark=\"-\"><li><p><span style=\"font-size: 16px;\">\u6aa2\u67e5\u985e\u548c\u65b9\u6cd5\u662f\u5426\u5177\u6709System.Runtime.CompileServices.ExtensionAttribute\u9019\u500b\u7279\u6027<\/span><\/p><\/li><\/ul><\/li><li><p>\u5728C#\u4e2d\uff0c\u4e00\u65e6<span spellcheck=\"false\"><span style=\"color: red;\">\u4f7f\u7528\u4e86this\u95dc\u9375\u5b57\u6a19\u8a18\u67d0\u500b\u975c\u614b\u65b9\u6cd5\u7684\u7b2c\u4e00\u500b\u53c3\u6578\uff0c\u7de8\u8b6f\u5668\u5c31\u6703\u5728\u5167\u90e8\u5411\u8a72\u65b9\u6cd5\u61c9\u7528\u4e00\u500b\u5b9a\u5236\u7279\u6027\uff08System.Code.dll\u4e2d\u7684ExtensionAttribute\uff09<\/span><\/span>\u3002\u8a72\u7279\u6027\u6703\u5728\u6700\u7d42\u751f\u6210\u6587\u4ef6\u5143\u6578\u64da\u4e2d\u6301\u4e45\u6027\u5730\u5b58\u5132\u4e0b\u4f86<\/p><ul data-mark=\"-\"><li><pre lang=\"il\" spellcheck=\"false\"><span role=\"presentation\">Method #1 (0600001a) <\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">MethodName: IndexOf (0600001A)<\/span><br \/><span role=\"presentation\">Flags \u00a0 \u00a0 : [Public] [Static] [HideBySig] [ReuseSlot]  (00000096)<\/span><br \/><span role=\"presentation\">\/\/...<\/span><br \/><span role=\"presentation\">CustomAttribute #1 (0c00000d)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<\/span><\/pre><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u4efb\u4f55\u975c\u614b\u985e\u53ea\u8981\u5305\u542b\u81f3\u5c11\u4e00\u500b\u64f4\u5c55\u65b9\u6cd5\uff0c\u5b83\u7684\u5143\u6578\u64da\u4e5f\u6703\u61c9\u7528\u9019\u500b\u7279\u6027<\/span><\/span><\/p><ul data-mark=\"-\"><li><pre lang=\"IL\" spellcheck=\"false\"><span role=\"presentation\">TypeDef #11 (0200000c)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">TypDefName: CLR_Ch8.Extensions  (0200000C)<\/span><br \/><span role=\"presentation\">Flags \u00a0 \u00a0 : [Public] [AutoLayout] [Class] [Abstract] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100181)<\/span><br \/><span role=\"presentation\">Extends \u00a0 : 0100000D [TypeRef] System.Object<\/span><br \/><span role=\"presentation\">Method #1 (0600001a) <\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">MethodName: IndexOf (0600001A)<\/span><br \/><span role=\"presentation\">\/\/...<\/span><br \/><span role=\"presentation\">CustomAttribute #1 (0c00000d)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<br \/><br \/><\/span><span role=\"presentation\">Method #2 (0600001b) <\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">MethodName: ShowItems (0600001B)<\/span><br \/><span role=\"presentation\">\/\/...<\/span><br \/><span role=\"presentation\">CustomAttribute #1 (0c00000e)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<br \/><br \/><\/span><span role=\"presentation\">Method #3 (0600001c) <\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">MethodName: InvokeAndCatch (0600001C)<\/span><br \/><span role=\"presentation\">\/\/...<\/span><br \/><span role=\"presentation\">(2) ParamToken : (08000017) Name : o flags: [none] (00000000)<\/span><br \/><span role=\"presentation\">CustomAttribute #1 (0c00000f)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<br \/><br \/><\/span><span role=\"presentation\">CustomAttribute #1 (0c00000c)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<\/span><\/pre><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u540c\u6a23\u5730\uff0c\u4efb\u4f55\u7a0b\u5e8f\u96c6\u53ea\u8981\u5305\u542b\u4e86\u4e00\u500b\u9019\u6a23\u7684\u975c\u614b\u985e\uff0c\u5b83\u7684\u5143\u6578\u64da\u4e5f\u6703\u61c9\u7528\u9019\u500b\u7279\u6027<\/span><\/span><\/p><ul data-mark=\"-\"><li><pre lang=\"il\" spellcheck=\"false\"><span role=\"presentation\">===========================================================<\/span><br \/><span role=\"presentation\">ScopeName : CLR_Ch8.dll<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">TypeDef #1 (02000002)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">TypeRef #1 (01000001)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">TypeSpec #1 (1b000001)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">MethodSpec #1 (2b000001)<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">Signature #1 (0x11000001)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">\/\/...<br \/><\/span><span role=\"presentation\">Assembly<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">\/\/...<\/span><br \/><span role=\"presentation\">CustomAttribute #1 (0c000001)<\/span><br \/><span role=\"presentation\">-------------------------------------------------------<\/span><br \/><span role=\"presentation\">CustomAttribute Type: 0a000001<\/span><br \/><span role=\"presentation\">CustomAttributeName: System.Runtime.CompilerServices.ExtensionAttribute :: instance void .ctor()<\/span><br \/><span role=\"presentation\">Length: 4<\/span><br \/><span role=\"presentation\">Value : 01 00 00 00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &gt; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &lt;<\/span><br \/><span role=\"presentation\">ctor args: ()<\/span><br \/><span role=\"presentation\">\/\/...<\/span><\/pre><\/li><\/ul><\/li><li><p><span spellcheck=\"false\"><span style=\"color: red;\">\u56e0\u6b64\uff0c\u5982\u679c\u4ee3\u78bc\u8abf\u7528\u4e86\u4e00\u500b\u4e0d\u5b58\u5728\u7684\u5be6\u4f8b\u65b9\u6cd5\uff0c\u7de8\u8b6f\u5668\u5c31\u6839\u64da\u9019\u500b\u7279\u6027\u7684\u5b58\u5728\u8207\u5426\uff0c\u4f86\u5feb\u901f\u6383\u7784\u5f15\u7528\u7684\u7a0b\u5e8f\u96c6\u3001\u975c\u614b\u985e\u3001\u64f4\u5c55\u65b9\u6cd5<\/span><\/span><\/p><\/li><\/ul>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-12ac465 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"12ac465\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4be6edd\" data-id=\"4be6edd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6b08aef elementor-widget-divider--view-line elementor-widget elementor-widget-divider\" data-id=\"6b08aef\" data-element_type=\"widget\" data-widget_type=\"divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-divider\">\n\t\t\t<span class=\"elementor-divider-separator\">\n\t\t\t\t\t\t<\/span>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6a1502a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6a1502a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ca56099\" data-id=\"ca56099\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f11dac6 elementor-widget elementor-widget-text-editor\" data-id=\"f11dac6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<h4 class=\"md-end-block md-heading\"><span style=\"text-decoration: underline;\"><strong><span class=\"md-plain md-expand\">\u53c3\u8003\u66f8\u76ee<\/span><\/strong><\/span><\/h4><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item md-focus-container\">\u300aCLR via C#\u300b\uff08\u7b2c4\u7248\uff09 Jeffrey Richter<\/li><li>\u300a\u6df1\u5165\u7406\u89e3C#\u300b\uff08\u7b2c3\u7248\uff09 Jon Skeet<\/li><\/ul>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u64f4\u5c55\u65b9\u6cd5\u5141\u8a31\u5b9a\u7fa9\u4e00\u500b\u975c\u614b\u65b9\u6cd5\uff0c\u4f46\u662f\u7528\u5be6\u4f8b\u65b9\u6cd5\u7684\u8a9e\u6cd5\u4f86\u8abf\u7528\uff0c\u4f7f\u4ee3\u78bc\u7684\u884c\u70ba\u9806\u5e8f\u770b\u4e0a\u53bb\u66f4\u5408\u7406<\/p>\n","protected":false},"author":1,"featured_media":947,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,27,18],"tags":[],"class_list":["post-3395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-reading-notes","category-c-sharp","category-developing"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/lonelinerd.com\/wp-content\/uploads\/2021\/03\/FeatureCover_ReadingNotes.png","_links":{"self":[{"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/comments?post=3395"}],"version-history":[{"count":32,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3395\/revisions"}],"predecessor-version":[{"id":3679,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3395\/revisions\/3679"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/media\/947"}],"wp:attachment":[{"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/media?parent=3395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/categories?post=3395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/tags?post=3395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}