{"id":3130,"date":"2023-05-16T00:38:05","date_gmt":"2023-05-15T16:38:05","guid":{"rendered":"https:\/\/lonelinerd.com\/?p=3130"},"modified":"2023-06-12T08:17:11","modified_gmt":"2023-06-12T00:17:11","slug":"class-basic-5","status":"publish","type":"post","link":"https:\/\/lonelinerd.com\/index.php\/2023\/05\/16\/class-basic-5\/","title":{"rendered":"C#\u7b46\u8a18 \u2013 \u985e\u578b\u57fa\u790e\uff08\u4e94\uff09 \u88dd\u7bb1\u62c6\u7bb1"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3130\" class=\"elementor elementor-3130\">\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-20d9374 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"20d9374\" 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-8110e8b\" data-id=\"8110e8b\" 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-993aed9 elementor-widget elementor-widget-text-editor\" data-id=\"993aed9\" 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<pre lang=\"c#\" spellcheck=\"false\"><span role=\"presentation\">int i = 5;<\/span>\n<span role=\"presentation\">object o = i; \/\/\u88dd\u7bb1<\/span>\n<span role=\"presentation\">int j = (int)o; \/\/\u62c6\u7bb1<\/span><\/pre><h5 style=\"font-style: normal;\"><span style=\"font-weight: bold;\">\u88dd\u7bb1<\/span><\/h5><ul data-mark=\"-\"><li><span spellcheck=\"false\"><span style=\"color: red;\">\u628a\u503c\u985e\u578b\u8f49\u63db\u6210\u4e00\u500b\u5f15\u7528\u985e\u578b\u6642\uff0c\u904b\u884c\u6642\u6703\u5728\u5806\u4e0a\u6839\u64da\u503c\u985e\u578b\u7684\u503c\u5275\u5efa\u4e00\u500b\u526f\u672c\uff0c<\/span><\/span><span style=\"font-size: 16px;\">\u7136\u5f8c\u5c07\u526f\u672c\u7684\u5f15\u7528\u5730\u5740\u8ce6\u7d66\u5c0d\u61c9\u7684\u5f15\u7528\u985e\u578b\u8b8a\u91cf\uff0c<\/span>\u6b64\u6642\u6539\u8b8a\u503c\u8b8a\u91cf\u7684\u503c\u6642\uff0c\u4e0d\u6703\u5c0d\u5f15\u7528\u8b8a\u91cf\u6307\u5411\u7684\u5c0d\u8c61\u9020\u6210\u5f71\u97ff<br \/><ul data-mark=\"-\"><li>\u88dd\u7bb1\u767c\u751f\u6642\u6a5f\uff1a<br \/><ul data-mark=\"-\"><li><span spellcheck=\"false\"><span style=\"color: red;\">\u8981\u7372\u53d6\u5c0d\u503c\u985e\u578b\u5be6\u4f8b\u7684\u5f15\u7528\uff0c\u5c07\u503c\u985e\u578b\u5be6\u4f8b\u50b3\u7d66\u9700\u8981\u7372\u53d6\u5f15\u7528\u985e\u578b\u7684\u65b9\u6cd5\u6642\uff1a<\/span><\/span><span spellcheck=\"false\"><span style=\"color: red;\"><br \/><\/span><\/span><br \/><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">\/\/ValueType<\/span><br \/><span role=\"presentation\">struct Point<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0public int x;<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0public int y;<\/span><br \/><span role=\"presentation\">}<br \/><\/span><span role=\"presentation\">public sealed class Program<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0public static void Main()<\/span><br \/><span role=\"presentation\"> \u00a0 {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0ArrayList a = new ArrayList();<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0Point p;<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0for(int i = 0; i &lt; 10; i++)<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 {<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0p.x = i;<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0p.y = i;<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0a.Add(p); \/\/ArrayList.Add(Object obj)\u63a5\u6536\u7684\u662f\u4e00\u500bObject\u985e\u578b\u7684\u53c3\u6578<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0 \u00a0 }<\/span><br \/><span role=\"presentation\"> \u00a0 }<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><li><p>\u4e0a\u4f8b\u4e2d\u7684Array.Add(Object obj)\uff0cAdd\u7372\u53d6\u7684\u662f\u5c0d\u6258\u7ba1\u5806\u4e0a\u7684\u4e00\u500b\u5c0d\u8c61\u5f15\u7528\u4f5c\u70ba\u53c3\u6578\uff1b\u4f46\u4ee3\u78bc\u50b3\u905e\u7684\u662f\u503c\u985e\u578b\u7684\u4e00\u500bp\u3002\u56e0\u6b64\uff0cPoint\u985e\u578b\u7684p\u9700\u8981\u88ab\u8f49\u63db\u6210\u300c\u5728\u6258\u7ba1\u5806\u4e2d\u7684\u5c0d\u8c61\uff0c\u7136\u5f8c\u88abAdd(Object obj)\u65b9\u6cd5\u7372\u53d6\u5176\u5f15\u7528\u3002<\/p><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u9084\u6709ToString()\/Equals()\/GetHashCode()\u7b49\u65b9\u6cd5\u4e5f\u6703\u7372\u53d6\u503c\u985e\u578b\u5be6\u4f8b\u7684\u5f15\u7528<\/span><\/span><\/li><\/ul><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u5c07\u503c\u4f5c\u70ba\u63a5\u53e3\u8868\u9054\u5f0f\u4f7f\u7528\u6642\uff08\u8ce6\u7d66\u4e00\u500b\u63a5\u53e3\u985e\u578b\u7684\u8b8a\u91cf\uff09\/\u628a\u5b83\u4f5c\u70ba\u63a5\u53e3\u985e\u578b\u7684\u53c3\u6578\u50b3\u905e\uff0c\u4e5f\u6703\u767c\u751f\u88dd\u7bb1<\/span><\/span><br \/><ul data-mark=\"-\"><li><p style=\"font-size: 15px;\">\u5c07\u503c\u985e\u578b\u7684<span spellcheck=\"false\"><span style=\"color: red;\">\u672a\u88dd\u7bb1\u5be6\u4f8b\u8f49\u578b\u70ba\u985e\u578b\u7684\u67d0\u500b\u63a5\u53e3\u6642\uff0c\u8981\u5c0d\u5be6\u4f8b\u9032\u884c\u88dd\u7bb1\u3002<\/span><\/span>\u56e0\u70ba\u63a5\u53e3\u8b8a\u91cf\u5fc5\u9808\u5305\u542b\u5c0d\u5806\u5c0d\u8c61\u7684\u5f15\u7528<\/p><\/li><\/ul><\/li><li style=\"font-size: 15px;\">\u53e6\u5916 <a href=\"https:\/\/lonelinerd.com\/index.php\/2023\/05\/16\/class-basic-4-2\/\">\u985e\u578b\u57fa\u790e\uff08\u56db\uff09<\/a>\u00a0\u4e2d\u63d0\u904e\uff0c\u672a\u88dd\u7bb1\u503c\u985e\u578b\u8f03\u5f15\u7528\u985e\u578b\u8f15\u662f\u56e0\u70ba\u503c\u4e0d\u5728\u6258\u7ba1\u5806\u4e0a\u5206\u914d\u4ee5\u53ca\u6c92\u6709\u5806\u4e0a\u6bcf\u500b\u5c0d\u8c61\u90fd\u6709\u7684\u5169\u500b\u984d\u5916\u6210\u54e1\uff08\u985e\u578b\u5c0d\u8c61\u6307\u91dd\u548c\u540c\u6b65\u584a\u7d22\u5f15\uff09<ul><li style=\"list-style-type: none;\"><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\"><span spellcheck=\"false\"><span style=\"color: red;\">\u800c\u6c92\u6709\u540c\u6b65\u584a\u7d22\u5f15\u4ee3\u78bc\u5c31\u4e0d\u80fd\u8b93\u591a\u500b\u7dda\u7a0b\u540c\u6b65\u5c0d\u5be6\u4f8b\u7684\u8a2a\u554f\uff08\u4f7f\u7528System.Threading.Monitor\u985e\u578b\u7684\u65b9\u6cd5\uff09<\/span><\/span><\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u56e0\u6b64\uff0c\u8981\u8b93<span spellcheck=\"false\"><span style=\"color: red;\">\u591a\u500b\u7dda\u7a0b\u540c\u6b65\u5c0d\u5be6\u4f8b\u7684\u8a2a\u554f\u6642\u5c31\u8981\u88dd\u7bb1<\/span><\/span><\/p><\/li><\/ul><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u96d6\u7136\u672a\u88dd\u7bb1\u503c\u985e\u578b\u6c92\u6709\u985e\u578b\u5c0d\u8c61\u6307\u91dd\uff0c\u4f46\u4ecd\u53ef\u4ee5\u8abf\u7528\u5f9eSystem.Object\u7e7c\u627f\u4e0b\u4f86\u7684\u865b\u65b9\u6cd5\u3002\uff08\u5982Equals\u3001GetHashCode\u3001ToString\uff09<\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u5982\u679c\u503c\u985e\u578b<span spellcheck=\"false\"><span style=\"color: red;\">\u91cd\u5beb\u4e86\u9019\u4e9b\u65b9\u6cd5\u4e26\u9032\u884c\u8abf\u7528\uff0c\u90a3\u9ebcCLR\u53ef\u4ee5\u975e\u865b\u5730\u8abf\u7528\u9019\u4e9b\u65b9\u6cd5\u4e14\u4e0d\u6703\u4f7f\u503c\u985e\u578b\u88dd\u7bb1<\/span><\/span><\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u70ba\u4e86\u8abf\u7528\u865b\u65b9\u6cd5\uff0cCLR\u9700\u8981\u5224\u65b7\u5c0d\u8c61\u7684\u985e\u578b\u4f86\u5b9a\u4f4d\u985e\u578b\u7684\u65b9\u6cd5\u8868<\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">JIT\u7de8\u8b6f\u6642\u767c\u73fe\u4e86\u672a\u88dd\u7bb1\u503c\u985e\u578b\u6240\u91cd\u5beb\u7684\u65b9\u6cd5\uff0c\u5c31\u6703\u751f\u6210\u4ee3\u78bc\u76f4\u63a5\u8abf\u7528\u8a72\u65b9\u6cd5\uff0c\u4e0d\u5fc5\u9032\u884c\u88dd\u7bb1\u64cd\u4f5c<\/p><\/li><\/ul><\/li><\/ul><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u4f46\u5982\u679c<span spellcheck=\"false\"><span style=\"color: red;\">\u503c\u985e\u578b\u8981\u8abf\u7528\u57fa\u985e\u7684\u5be6\u73fe\u6642\uff0c\u5c31\u6703\u767c\u751f\u88dd\u7bb1\uff0c\u4ee5\u4fbf\u901a\u904ethis\u6307\u91dd\u5c07\u4e00\u500b\u5806\u5c0d\u8c61\u7684\u5f15\u7528\u50b3\u7d66\u57fa\u65b9\u6cd5<\/span><\/span><\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">public override string ToString()<\/span><br \/><span role=\"presentation\">{<\/span><br \/><span role=\"presentation\"> \u00a0 \u00a0return base.ToString();<\/span><br \/><span role=\"presentation\">}<\/span><\/pre><\/li><\/ul><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u800c\u5982\u679c<span spellcheck=\"false\"><span style=\"color: red;\">\u8abf\u7528\u7684\u662fSystem.Object\u7684\u975e\u865b\u65b9\u6cd5\uff08GetType\u3001MemberwiseClone\uff09\uff0c\u5c31\u80af\u5b9a\u6703\u88dd\u7bb1<\/span><\/span>\uff0c\u56e0\u70ba\u662fSystem.Object\u5b9a\u7fa9\u7684\u65b9\u6cd5<\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u70ba\u4e86<span spellcheck=\"false\"><span style=\"color: red;\">\u8abf\u7528\u9019\u4e9b\u65b9\u6cd5\uff0cCLR\u5fc5\u9808\u4f7f\u7528\u6307\u5411\u985e\u578b\u5c0d\u8c61\u7684\u6307\u91dd\uff0c\u800c\u9019\u500b\u6307\u91dd\u53ea\u80fd\u901a\u904e\u88dd\u7bb1\u4f86\u7372\u5f97<\/span><\/span><span style=\"font-style: inherit; font-weight: inherit;\">\u00a0<\/span><\/p><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u88dd\u7bb1\u5177\u9ad4\u904b\u4f5c\u6a5f\u5236<\/span><\/span>\uff1a<br \/><ul data-mark=\"-\"><li><span spellcheck=\"false\"><span style=\"color: red;\">\u5728\u6258\u7ba1\u5806\u4e2d\u5206\u914d\u5167\u5b58\uff0c\u5206\u914d\u7684\u5167\u5b58\u91cf\u662f\u503c\u985e\u578b\u5404\u5b57\u6bb5\u6240\u9700 + \u5806\u5c0d\u8c61\u7684\u984d\u5916\u6210\u54e1\u6240\u9700\uff08\u985e\u578b\u5c0d\u8c61\u6307\u91dd\u548c\u540c\u6b65\u584a\u7d22\u5f15\uff09<\/span><\/span><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u5c07\u503c\u985e\u578b\u7684\u5b57\u6bb5\u7684\u503c\u8907\u88fd\u5230\u65b0\u5206\u914d\u7684\u5806\u5167\u5b58\u4e2d<\/span><\/span><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u628a\u5806\u5167\u5b58\u65b0\u5efa\u7684\u5c0d\u8c61\u7684\u5730\u5740\u8fd4\u56de\u51fa\u53bb<\/span><\/span><\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u8a72\u5c0d\u8c61\u6703\u4e00\u76f4\u5b58\u5728\u65bc\u5806\u4e2d\uff0c\u76f4\u81f3\u88abGC\u56de\u6536<\/span><\/span><br \/><ul data-mark=\"-\"><li>\u56e0\u6b64\uff0c\u5df2\u88dd\u7bb1\u7684\u503c\u985e\u578b\u7684\u751f\u5b58\u671f\u6703<span spellcheck=\"false\"><span style=\"color: red;\">\u8d85\u904e\u672a\u88dd\u7bb1\u503c\u985e\u578b\u7684\u751f\u5b58\u671f<\/span><\/span><\/li><\/ul><\/li><\/ul><\/li><li>\u5c0d\u503c\u985e\u578b\u5be6\u4f8b\u9032\u884c\u88dd\u7bb1\u7684IL\u4ee3\u78bc\u4e5f\u7531C#\u7de8\u8b6f\u5668\u81ea\u52d5\u751f\u6210\uff08\u6307\u4ee4\u70babox\uff09<br \/><ul data-mark=\"-\"><li>C#\u7de8\u8b6f\u5668\u6703\u6aa2\u6e2c\u5230\u4ee3\u78bc\u662f\u5411\u8981\u6c42\u5f15\u7528\u985e\u578b\u7684\u65b9\u6cd5\u50b3\u905e\u503c\u985e\u578b\uff0c\u4e26\u81ea\u52d5\u751f\u6210\u4ee3\u78bc\u5be6\u73fe\u88dd\u7bb1<\/li><\/ul><\/li><\/ul><h5><strong>\u62c6\u7bb1<\/strong><\/h5><ul data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\"><span spellcheck=\"false\">\u628a\u5f15\u7528\u985e\u578b\u6307\u5411\u7684\u5c0d\u8c61\u8f49\u6210\u503c\u985e\u578b\u6642<span style=\"color: red;\">\uff0c\u904b\u884c\u6642\u6703\u7372\u53d6\u5df2\u88dd\u7bb1\u5c0d\u8c61\u7684\u5404\u500b\u5b57\u6bb5\u7684\u5730\u5740\uff0c<\/span><\/span><span style=\"font-size: 15px;\">\u62c6\u7bb1\u4e4b\u5f8c\uff0c\u6703<\/span><span style=\"font-size: 15px;\" spellcheck=\"false\"><span style=\"color: red;\">\u7dca\u63a5\u8457\u767c\u751f\u4e00\u6b21\u5b57\u6bb5\u8907\u88fd\uff0c\u518d<\/span><\/span><span style=\"color: red; font-size: 15px;\">\u628a\u5177\u9ad4\u7684\u503c<\/span><span style=\"color: red; font-size: 15px;\" spellcheck=\"false\">\u8ce6\u5230\u503c\u985e\u578b\u7684\u8b8a\u91cf\u4e2d<\/span><\/p><ul data-mark=\"-\"><li>\u65b0\u7684\u503c\u985e\u578b\u8b8a\u91cf\u8207\u5f15\u7528\u6307\u5411\u7684\u5c0d\u8c61\u6c92\u6709\u4efb\u4f55\u95dc\u4fc2<\/li><\/ul><\/li><li><pre lang=\"c#\" spellcheck=\"false\">public static void Main() {<br \/>    ArrayList a = new ArrayList();<br \/>    a.Add(new Point());<br \/>    Point p = (Point)a[0];<br \/>}<\/pre><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u672c\u4f8b\u7372\u53d6ArrayList\u4e2d\u7684\u5f15\u7528\u985e\u578bObject\u5be6\u4f8b\uff0c\u4e26\u5c07\u5176\u8f49\u578b\u70ba\u503c\u985e\u578bPoint\u7684\u5be6\u4f8bp\u4e2d<\/p><ul><li style=\"list-style-type: none;\"><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u7b2c\u4e00\u6b65\u70ba\u7372\u53d6a[0]\uff08\u5df2\u88dd\u7bb1\u7684Point\u5c0d\u8c61\uff09\u4e2d\u7684\u5404\u500bPoint\u5b57\u6bb5\u7684\u5730\u5740\uff08\u62c6\u7bb1\uff09<\/p><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u7b2c\u4e8c\u6b65\u662f\u5c07\u5b57\u6bb5\u5305\u542b\u7684\u503c\u8907\u88fd\u5230\u57fa\u65bc\u68e7\u7684\u503c\u985e\u578b\u5be6\u4f8b\u4e2d<\/p><\/li><\/ul><\/li><\/ul><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u76f8\u6bd4\u88dd\u7bb1\u800c\u8a00\uff0c<span spellcheck=\"false\"><span style=\"color: red;\">\u62c6\u7bb1\u7684\u4ee3\u50f9\u8981\u4f4e\u7684\u591a<\/span><\/span><\/p><ul style=\"font-size: 15px;\" data-mark=\"-\"><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\"><span spellcheck=\"false\"><span style=\"color: red;\">\u62c6\u7bb1\u5be6\u969b\u662f\u7372\u53d6\u6307\u91dd\u7684\u904e\u7a0b\uff0c\u8a72\u6307\u91dd\u6307\u5411\u5305\u542b\u4e00\u500b\u5c0d\u8c61\u4e2d\u7684\u539f\u59cb\u503c\u985e\u578b\uff08\u6578\u64da\u5b57\u6bb5\uff09<\/span><\/span><\/p><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u53e6\u5916\uff0c<span spellcheck=\"false\"><span style=\"color: red;\">\u6307\u91dd\u6307\u5411\u7684\u662f\u5df2\u88dd\u7bb1\u5be6\u4f8b\u4e2d\u672a\u88dd\u7bb1\u7684\u90e8\u5206<\/span><\/span><\/p><\/li><li style=\"font-size: 15px;\"><p style=\"font-size: 15px;\">\u6240\u4ee5\uff0c\u62c6\u7bb1\u672c\u8eab<span spellcheck=\"false\"><span style=\"color: red;\">\u4e0d\u8981\u6c42\u5728\u5167\u5b58\u9032\u884c\u5b57\u7bc0\u7684\u8907\u88fd\uff0c<\/span><\/span><span style=\"font-size: 15px;\">\u4f46\u662f\uff0c\u7dca\u63a5\u8457\u62c6\u7bb1\u6703\u767c\u751f\u4e00\u6b21\u5b57\u6bb5\u8907\u88fd<\/span><\/p><\/li><\/ul><\/li><li>\u62c6\u7bb1\u4e00\u822c\u767c\u751f\u5728\u5f37\u5236\u8f49\u63db\u4e2d\uff0c<span style=\"font-size: 16px;\">\u5982\uff1a int j = (int)o<\/span><\/li><\/ul><h5><strong>\u88dd\u62c6\u7bb1\u64cd\u4f5c\u7684\u554f\u984c<\/strong><\/h5><ul data-mark=\"-\"><li style=\"list-style-type: none;\"><ul data-mark=\"-\"><li>\u964d\u4f4e\u6027\u80fd\uff0c\u63d0\u9ad8\u64cd\u4f5c\u958b\u92b7<\/li><li><span spellcheck=\"false\"><span style=\"color: red;\">\u5275\u5efa\u5927\u91cf\u591a\u9918\u5c0d\u8c61\uff0c\u52a0\u91cdGC\u58d3\u529b<\/span><\/span><\/li><\/ul><\/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-3dd926b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3dd926b\" 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-5a38d08\" data-id=\"5a38d08\" 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-9d465c2 elementor-widget elementor-widget-text-editor\" data-id=\"9d465c2\" 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>\u95dc\u65bc\u88dd\u7bb1\u548c\u62c6\u7bb1\u7684\u5176\u4ed6\u6ce8\u610f\u9ede<\/strong><\/h5><ul data-mark=\"-\"><li><p>FCL\u5f80\u5f80\u70ba\u4e00\u4e9b\u65b9\u6cd5\u63d0\u4f9b\u4e86\u5404\u7a2e\u985e\u578b\u7684\u91cd\u8f09\uff0c\u5982Console.WriteLine()<\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">public static void WriteLine(Boolean);<\/span><br \/><span role=\"presentation\">public static void WriteLine(Char);<\/span><br \/><span role=\"presentation\">public static void WriteLine(String);<\/span><br \/><span role=\"presentation\">public static void WriteLine(Object);<\/span><br \/><span role=\"presentation\">...<\/span><\/pre><\/li><li><p>\u5927\u591a\u6578\u65b9\u6cd5\u63d0\u4f9b\u91cd\u8f09\u7684\u552f\u4e00\u76ee\u7684\u5c31\u662f\u6e1b\u5c11\u5e38\u7528\u503c\u985e\u578b\u7684\u88dd\u7bb1\u6b21\u6578<\/p><\/li><li><p>\u5982\u679c\u9019\u4e9b\u65b9\u6cd5\u4e0d\u5b58\u5728\u8207\u503c\u985e\u578b\u5c0d\u61c9\u7684\u53c3\u6578\u7684\u91cd\u8f09\uff0c\u90a3\u9ebc\u8abf\u7528\u7684\u80af\u5b9a\u662f\u4e00\u500bObject\u53c3\u6578\u7684\u7248\u672c\uff0c\u5f9e\u800c\u5c0e\u81f4\u88dd\u7bb1\u3002\u5c24\u5176\u662f\u4f7f\u7528\u81ea\u5b9a\u7fa9\u7684\u503c\u985e\u578b\u6642\u3002<\/p><ul data-mark=\"-\"><li><p>\u56e0\u6b64\uff0c<span spellcheck=\"false\"><span style=\"color: red;\">\u5b9a\u7fa9\u81ea\u5df1\u7684\u985e\u6642\uff0c\u53ef\u5c07\u985e\u4e2d\u7684\u65b9\u6cd5\u5b9a\u7fa9\u70ba\u6cdb\u578b\uff0c\u518d\u7d04\u675f\u70ba\u503c\u985e\u578b\uff0c\u9019\u6a23\u65b9\u6cd5\u5c31\u53ef\u4ee5\u7372\u53d6\u4efb\u4f55\u503c\u985e\u578b\u800c\u4e0d\u5fc5\u88dd\u7bb1<\/span><\/span><\/p><\/li><\/ul><\/li><\/ul><\/li><li><p>\u53e6\u5916\uff0c\u5982\u679c\u77e5\u9053\u81ea\u5df1\u7684\u4ee3\u78bc\u6703\u4f7f\u7de8\u8b6f\u5668<span spellcheck=\"false\"><span style=\"color: red;\">\u53cd\u8986\u5c0d\u4e00\u500b\u503c\u9032\u884c\u88dd\u7bb1\uff0c\u5c31\u61c9\u8a72\u6539\u7528\u624b\u52d5\u65b9\u5f0f\u5148\u5c0d\u503c\u985e\u578b\u9032\u884c\u4e00\u6b21\u88dd\u7bb1<\/span><\/span>\uff0c\u4e26\u5728\u5f8c\u7e8c\u76f4\u63a5\u4f7f\u7528\u9019\u500b\u5df2\u88dd\u7bb1\u7684\u503c<\/p><ul data-mark=\"-\"><li><pre lang=\"C#\" spellcheck=\"false\"><span role=\"presentation\">int a = 5;<\/span><br \/><span role=\"presentation\">Console.WriteLine(\"{0}, {1}, {2}\", a, a, a); \/\/\u88dd\u7bb13\u6b21<br \/><br \/><\/span><span role=\"presentation\">Object o = a; \/\/\u624b\u52d5\u88dd\u7bb11\u6b21<\/span><br \/><span role=\"presentation\">Console.WriteLine(\"{0}, {1}, {2}\", o, o, o); \/\/\u4e0d\u9700\u88dd\u7bb1<\/span><\/pre><\/li><\/ul><\/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-01a9a29 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"01a9a29\" 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-1659631\" data-id=\"1659631\" 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-57fa99e elementor-widget-divider--view-line elementor-widget elementor-widget-divider\" data-id=\"57fa99e\" 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-db40ac7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"db40ac7\" 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-4e3c358\" data-id=\"4e3c358\" 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-39e8f50 elementor-widget elementor-widget-text-editor\" data-id=\"39e8f50\" 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>\u88dd\u7bb1\uff1a\u628a\u503c\u985e\u578b\u8f49\u63db\u6210\u4e00\u500b\u5f15\u7528\u985e\u578b\u6642\uff0c\u904b\u884c\u6642\u6703\u5728\u5806\u4e0a\u6839\u64da\u503c\u985e\u578b\u7684\u503c\u5275\u5efa\u4e00\u500b\u526f\u672c\uff0c\u7136\u5f8c\u5c07\u526f\u672c\u7684\u5f15\u7528\u5730\u5740\u8ce6\u7d66\u5c0d\u61c9\u7684\u5f15\u7528\u985e\u578b\u8b8a\u91cf\uff1b\u62c6\u7bb1\uff1a\u628a\u5f15\u7528\u985e\u578b\u6307\u5411\u7684\u5c0d\u8c61\u8f49\u6210\u503c\u985e\u578b\u6642\uff0c\u904b\u884c\u6642\u6703\u7372\u53d6\u5df2\u88dd\u7bb1\u5c0d\u8c61\u7684\u5404\u500b\u5b57\u6bb5\u7684\u5730\u5740\uff0c\u7dca\u63a5\u8457\u767c\u751f\u4e00\u6b21\u5b57\u6bb5\u8907\u88fd\uff0c\u518d\u628a\u5177\u9ad4\u7684\u503c\u8ce6\u5230\u503c\u985e\u578b\u7684\u8b8a\u91cf\u4e2d<\/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-3130","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\/3130","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=3130"}],"version-history":[{"count":60,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3130\/revisions"}],"predecessor-version":[{"id":3768,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/posts\/3130\/revisions\/3768"}],"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=3130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/categories?post=3130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lonelinerd.com\/index.php\/wp-json\/wp\/v2\/tags?post=3130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}