{"id":3287,"date":"2023-05-27T08:13:33","date_gmt":"2023-05-27T00:13:33","guid":{"rendered":"https:\/\/lonelinerd.com\/?p=3287"},"modified":"2023-06-03T00:54:53","modified_gmt":"2023-06-02T16:54:53","slug":"const","status":"publish","type":"post","link":"https:\/\/lonelinerd.com\/index.php\/2023\/05\/27\/const\/","title":{"rendered":"C#\u7b46\u8a18 \u2013 \u5e38\u91cf"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3287\" class=\"elementor elementor-3287\">\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-a8cd214 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a8cd214\" 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-3494b18\" data-id=\"3494b18\" 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-c739e58 elementor-widget elementor-widget-text-editor\" data-id=\"c739e58\" 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 class=\"md-end-block md-heading\"><strong><span class=\"md-plain\">\u5e38\u91cf<\/span><\/strong><\/h5><ul><li><span class=\"md-plain\">\u5e38\u91cf\u503c\u5f9e\u4e0d\u8b8a\u5316\uff0c\u56e0\u6b64\u7e3d\u662f\u88ab\u8996\u70ba<\/span><span class=\"md-html-inline\" spellcheck=\"false\"><span class=\"md-plain\">\u975c\u614b\u6210\u54e1<\/span><\/span><\/li><\/ul><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"c#\" spellcheck=\"false\"><span role=\"presentation\"><span class=\"cm-keyword\">const<\/span> <span class=\"cm-variable-3\">int<\/span> <span class=\"cm-variable\">someConst<\/span> <span class=\"cm-operator\">=<\/span> <span class=\"cm-number\">1<\/span>;<\/span><\/pre><\/li><li class=\"md-list-item\"><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"il\" spellcheck=\"false\"><span role=\"presentation\">\/\/Check in ildasm<\/span><br \/><span role=\"presentation\">someConst : private static literal int32<\/span><\/pre><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u5e38\u91cf\u503c\u5fc5\u9808\u80fd\u5728\u7de8\u8b6f\u6642\u78ba\u5b9a\uff0c\u78ba\u5b9a\u5f8c\uff0c\u7de8\u8b6f\u5668\u5c07\u5e38\u91cf\u4fdd\u5b58\u5230\u7a0b\u5e8f\u96c6\u5143\u6578\u64da\u4e2d<\/span><\/span><\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u56e0\u6b64\uff0c<\/span><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u5e38\u91cf\u985e\u578b\u5fc5\u9808\u662f\u7de8\u8b6f\u5668\u53ef\u4ee5\u8b58\u5225\u7684\u57fa\u5143\u985e\u578b<\/span><\/span><\/span><\/p><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">C#\u5141\u8a31\u5b9a\u7fa9\u975e\u57fa\u5143\u985e\u578b\u7684\u5e38\u91cf\uff0c\u4f46\u503c\u9700\u8a2d\u70banull<\/span><\/p><\/li><\/ul><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u5b9a\u7fa9\u5e38\u91cf\u5c07\u5c0e\u81f4\u5143\u6578\u64da\u7684\u5275\u5efa<\/span><\/span><\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u4ee3\u78bc\u5f15\u7528\u5e38\u91cf\u6642\uff0c\u7de8\u8b6f\u5668\u5728\u5b9a\u7fa9\u5e38\u91cf\u7684\u7a0b\u5e8f\u96c6\u7684\u5143\u6578\u64da\u4e2d\u67e5\u627e\u8a72\u5e38\u91cf\u4e26\u63d0\u53d6\u5e38\u91cf\u7684\u503c\uff0c\u7136\u5f8c\u5c07\u5176\u5d4c\u5165\u751f\u6210\u7684IL\u4ee3\u78bc\u4e2d<\/span><\/span><\/span><\/p><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u56e0\u6b64\uff0c\u7531\u65bc<\/span><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u5e38\u91cf\u503c\u76f4\u63a5\u5d4c\u5165\u4ee3\u78bc\u4e2d\uff0c\u6240\u4ee5\u904b\u884c\u6642\u4e0d\u9700\u8981\u70ba\u5e38\u91cf\u5206\u914d\u4efb\u4f55\u5167\u5b58<\/span><\/span><\/span><\/p><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u53e6\u5916\uff0c<\/span><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u4e0d\u80fd\u7372\u53d6\u5e38\u91cf\u5730\u5740\uff0c\u4e5f\u4e0d\u80fd\u4ee5\u50b3\u5f15\u7528\u7684\u65b9\u5f0f\u50b3\u905e\u5e38\u91cf<\/span><\/span><\/span><\/p><\/li><\/ul><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u5e38\u91cf\u5728<\/span><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u7248\u672c\u63a7\u5236\u4e0a\u975e\u5e38\u4e0d\u65b9\u4fbf<\/span><\/span><\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u5047\u5982\u6709\u4ee5\u4e0b\u4e00\u500b\u5b9a\u7fa9\u4e86\u5e38\u91cf\u7684dll<\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\"><span class=\"cm-keyword\">public<\/span> <span class=\"cm-keyword\">sealed<\/span> <span class=\"cm-keyword\">class<\/span> <span class=\"cm-def\">SomeLibraryType<\/span><\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0<span class=\"cm-keyword\">public<\/span> <span class=\"cm-keyword\">const<\/span> <span class=\"cm-variable-3\">int<\/span> <span class=\"cm-variable\">MaxEntriesInList<\/span> <span class=\"cm-operator\">=<\/span> <span class=\"cm-number\">1000<\/span>;<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><\/ul><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-plain\">\u6709\u5f15\u7528\u4e86\u4e0a\u8ff0dll\uff0c\u4e26\u5f15\u7528\u4e86\u5e38\u91cf\u7684exe<\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\"><span class=\"cm-keyword\">public<\/span> <span class=\"cm-keyword\">sealed<\/span> <span class=\"cm-keyword\">class<\/span> <span class=\"cm-def\">Program<\/span><\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0<span class=\"cm-keyword\">public<\/span> <span class=\"cm-keyword\">static<\/span> <span class=\"cm-keyword\">void<\/span> <span class=\"cm-variable\">Main<\/span>()<\/span><br \/><span role=\"presentation\"> \u00a0  {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-variable\">Console<\/span>.<span class=\"cm-variable\">WriteLine<\/span>(<span class=\"cm-string\">\"Max Entries supported in list: \"<\/span> <span class=\"cm-operator\">+<\/span><\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-variable\">SomeLibraryType<\/span>.<span class=\"cm-variable\">MaxEntriesInList<\/span>);<\/span><br \/><span role=\"presentation\">\u200b<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0<span class=\"cm-variable\">Console<\/span>.<span class=\"cm-variable\">ReadLine<\/span>();<\/span><br \/><span role=\"presentation\"> \u00a0  }<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><\/ul><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u5728\u751f\u6210exe\u6642\uff0c\u7de8\u8b6f\u5668\u6703\u6ce8\u610f\u5230\u5f15\u7528\u7684\u5e38\u91cf\uff0c\u4e26\u5c07\u5e38\u91cf\u76f4\u63a5\u5d4c\u5165\u5230\u61c9\u7528\u7684IL\u4ee3\u78bc\u4e2d\uff1b\u800c\u4e0d\u662f\u53bb\u52a0\u8f09\u5b9a\u7fa9\u5e38\u91cf\u7684DLL\u4e26\u53d6\u5f97\u5e38\u91cf\u503c<\/span><\/span><\/span><\/p><ul class=\"ul-list\" data-mark=\"-\"><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u9019\u4f7f\u5f97\u5373\u4f7f\u91cd\u65b0\u4fee\u6539\u4e26\u5c0e\u51faDLL\u6587\u4ef6\u4e5f\u4e0d\u6703\u5f71\u97ff\u5230\u61c9\u7528\u7a0b\u5e8f\u88e1\u5d4c\u5165\u7684\u5e38\u91cf\u503c<\/span><\/span><\/span><\/p><\/li><li class=\"md-list-item\"><p class=\"md-end-block md-p\"><span class=\"md-html-inline\" spellcheck=\"false\"><span style=\"color: red;\"><span class=\"md-plain\">\u61c9\u7528\u7a0b\u5e8f\u5fc5\u9808\u91cd\u65b0\u6253\u5305\u4e00\u6b21\u3001\u91cd\u65b0\u5d4c\u5165\u4e00\u6b21\u5e38\u91cf\u624d\u53ef\u4ee5\u66f4\u65b0\u5e38\u91cf\u503c<\/span><\/span><\/span><\/p><\/li><li class=\"md-list-item\"><pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"IL\" spellcheck=\"false\"><span role=\"presentation\">IL_0000:  nop<\/span><br \/><span role=\"presentation\">IL_0001:  ldstr \u00a0 \u00a0  \"Max Entries supported in list: \"<\/span><br \/><span role=\"presentation\">IL_0006:  ldc.i4 \u00a0 \u00a0 0x3e8<\/span><br \/><span role=\"presentation\">IL_000b:  stloc.0<\/span><br \/><span role=\"presentation\">IL_000c:  ldloca.s \u00a0 V_0<\/span><br \/><span role=\"presentation\">IL_000e:  call \u00a0 \u00a0 \u00a0 instance string [mscorlib]System.Int32::ToString()<\/span><br \/><span role=\"presentation\">IL_0013:  call \u00a0 \u00a0 \u00a0 string [mscorlib]System.String::Concat(string,<\/span><br \/><span role=\"presentation\">string)<\/span><br \/><span role=\"presentation\">IL_0018:  call \u00a0 \u00a0 \u00a0 void [mscorlib]System.Console::WriteLine(string)<\/span><\/pre><\/li><\/ul><\/li><\/ul><\/li><\/ul><div class=\"md-hr md-end-block\" tabindex=\"-1\"><hr \/><\/div>\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-6be1e12 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6be1e12\" 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-63fb442\" data-id=\"63fb442\" 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-bf975ac elementor-widget-divider--view-line elementor-widget elementor-widget-divider\" data-id=\"bf975ac\" 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-57e1a5f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"57e1a5f\" 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-ddcde06\" data-id=\"ddcde06\" 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-561b251 elementor-widget elementor-widget-text-editor\" data-id=\"561b251\" 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><\/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>\u5e38\u91cf\u503c\u5fc5\u9808\u80fd\u5728\u7de8\u8b6f\u6642\u78ba\u5b9a\uff0c\u78ba\u5b9a\u5f8c\uff0c\u7de8\u8b6f\u5668\u5c07\u5e38\u91cf\u4fdd\u5b58\u5230\u7a0b\u5e8f\u96c6\u5143\u6578\u64da\u4e2d\uff0c\u56e0\u6b64\uff0c\u5e38\u91cf\u985e\u578b\u5fc5\u9808\u662f\u7de8\u8b6f\u5668\u53ef\u4ee5\u8b58\u5225\u7684\u57fa\u5143\u985e\u578b<\/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-3287","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\/3287","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=3287"}],"version-history":[{"count":16,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3287\/revisions"}],"predecessor-version":[{"id":3515,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3287\/revisions\/3515"}],"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=3287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/categories?post=3287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/tags?post=3287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}