{"id":2016,"date":"2021-09-18T01:46:51","date_gmt":"2021-09-17T17:46:51","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=2016"},"modified":"2022-02-16T21:47:28","modified_gmt":"2022-02-16T13:47:28","slug":"variable-int-string","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2021\/09\/18\/variable-int-string\/","title":{"rendered":"D-27-\u8b8a\u6578 variable ? int ? string"},"content":{"rendered":"<h1>\u8a8d\u8b58\u8b8a\u6578 variable<\/h1>\n<p>\u5728\u6628\u5929\u7684\u6b77\u7a0b\u4e2d\u5c0f\u5149\u5b78\u7fd2\u5230\u5982\u4f55\u900f\u904edotnet cli\u4f86\u7522\u751f\u5c08\u6848\u8ddf\u65b9\u6848\uff0c\u4e26\u4e14\u900f\u904e<code>dotnet run<\/code>\u4f86\u57f7\u884c\u5c08\u6848\uff0c\u5df2\u7d93\u4e00\u4e9b\u8207\u958b\u767c\u76f8\u95dc\u7684\u6307\u4ee4\uff0c\u90a3\u4eca\u5929\u6e96\u5099\u505a\u4e9b\u4ec0\u9ebc\u5462\uff1f<\/p>\n<p><!--more--><\/p>\n<h2>\u958b\u767c\u7684\u7684\u7b2c\u4e00\u4ef6\u4e8b<\/h2>\n<p>\u300c\u524d\u8f29\uff0c\u4eca\u5929\u4f86\u958b\u767c\u5427\uff0c\u6211\u5011\u4f86\u505a\u9ede\u6771\u897f\u5427\u300d<br \/>\n\u4e00\u5982\u5f80\u6614\u7684\uff0c\u5c0f\u5149\u4e00\u5230\u516c\u53f8\u5c31\u8feb\u4e0d\u53ca\u5f85\u7684\u6e96\u5099\u958b\u59cb\u958b\u767c\uff0c\u4e0d\u904e\u5927\u982d\u4e00\u5982\u5f80\u6614\u7684\u57cb\u982d\u5de5\u4f5c\uff0c\u4e0d\u904e\u807d\u5230\u5c0f\u5149\u9019\u9ebc\u8aaa\u4e4b\u5f8c\u904e\u4e86\u5e7e\u79d2\u5f8c\u5927\u982d\u62ac\u8d77\u982d\u4f86\u4e86\uff0c\u4e26\u4e14\u9019\u9ebc\u8aaa\u9053\u3002<br \/>\n\u300c\u597d\u554a\uff0c\u6211\u5011\u4eca\u5929\u4f86\u958b\u767c\u4e00\u500b\u6703\u5c0d\u4eba\u8aaahello\u7684\u7a0b\u5f0f\u5427\u3002\u300d<br \/>\n\u807d\u5230\u9019\u4ef6\u4e8b\u5c0f\u5149\u958b\u59cb\u6469\u62f3\u64e6\u638c\u6e96\u5099\u958b\u59cb\u958b\u767c\uff0c\u4f46\u662f\u5750\u5728\u96fb\u8166\u524d\u9762\u537b\u4e00\u52d5\u4e5f\u4e0d\u52d5\uff0c\u904e\u4e86\u4e94\u79d2\u5f8c\u5c0f\u5149\u6293\u6293\u982d\u4e26\u8f49\u982d\u904e\u4f86\u5c0d\u8457\u5927\u982d\u8aaa\u3002<br \/>\n\u300c\u524d\u8f29\uff0c\u6211\u8a72\u5f9e\u54ea\u88e1\u958b\u59cb\u5462\uff1f\u300d<br \/>\n\u300c\u54c8\u54c8\u54c8\u50bb\u5c0f\u5b50\uff0c\u6709\u554f\u984c\u662f\u6b63\u5e38\u7684\uff0c\u6211\u5011\u4f86\u8a8d\u8b58\u8b8a\u6578\u5427\u3002\u300d<\/p>\n<h3>\u8b8a\u6578 variable<\/h3>\n<p>\u8b8a\u6578\u7c21\u55ae\u8aaa\u660e\u5c31\u662f\u7522\u751f\u4e00\u584a\u8a18\u61b6\u9ad4\u7a7a\u9593\u4f86\u5b58\u653e\u8cc7\u6599\u7684\u6771\u897f\uff0c\u8b8a\u6578\u6709\u591a\u7a2e\u578b\u5225\uff0c\u800cc#\u662f\u5f37\u578b\u5225\u7684\u8a9e\u8a00\uff0c\u6240\u4ee5\u8981\u4f7f\u7528\u4e00\u584a\u5b58\u653e\u8a18\u61b6\u9ad4\u7a7a\u9593\u7684\u8b8a\u6578\u524d\u8981\u5148\u5ba3\u544a\u5176\u578b\u5225\uff0c\u800c\u9019\u908a\u4e0d\u591a\u8aaa\u660e\u6709\u54ea\u4e9b\u578b\u5225\uff0c\u53ea\u91dd\u5c0d\u6574\u6578\u8ddf\u5b57\u4e32\u4f86\u8aaa\u660e\u8b8a\u6578\u8981\u5982\u4f55\u4f7f\u7528\uff0c\u5982\u679c\u6709\u8208\u8da3\u4e86\u89e3\u8b8a\u6578\u5167\u5bb9\u7684\u670b\u53cb\u5011\u8acb\u5230<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/builtin-types\/built-in-types\" title=\"msdn \u5167\u5efa\u578b\u5225\" rel=\"nofollow noopener\" target=\"_blank\">msdn \u5167\u5efa\u578b\u5225<\/a>\u4f86\u67e5\u95b1\u3002<\/p>\n<h3>\u5ba3\u544a\u8b8a\u6578<\/h3>\n<p>\u5ba3\u544a\u8b8a\u6578\u7684\u65b9\u5f0f\u6709\u5169\u7a2e\uff0c\u4e00\u7a2e\u662f\u76f4\u63a5\u5ba3\u544a\uff0c\u4e00\u7a2e\u662f\u96b1\u542b\u8b8a\u6578\u7684\u65b9\u5f0f\uff0c\u8acb\u5927\u5bb6\u5148\u770b\u770b\u4e0b\u5217\u4f8b\u5b50\u3002<\/p>\n<pre><code class=\"language-cs\">string name1 = &quot;\u5c0f\u5149&quot;;\nvar name2 = &quot;\u5927\u982d&quot;;<\/code><\/pre>\n<p>\u5176\u4e2d\u4e0a\u8ff0\u4f8b\u5b50\u4e2d\u7684\u5169\u500b\u8b8a\u6578\u90fd\u662f\u5b57\u4e32\uff0c\u800c\u5176\u4e2d\u7684<code>name2<\/code>\u5c31\u662f\u96b1\u542b\u8b8a\u6578\uff0c\u7c21\u55ae\u8aaa\u5c31\u662f\u5728\u8ce6\u503c\u5f8c\u4ed6\u5c31\u662f\u56fa\u5b9a\u578b\u5225\u4e86\uff0c\u800c\u5176\u4e2d\u7684<code>var name2<\/code>\u8ddf<code>string name1<\/code>\u5c31\u662f\u5ba3\u544a\u8b8a\u6578\uff0c\u4e0d\u904e\u96b1\u542b\u8b8a\u6578\u4e0d\u80fd\u53ea\u662f\u5ba3\u544a\u800c\u5df2\uff0c\u800c\u662f\u8981\u5ba3\u544a\u5f8c\u7acb\u523b\u7d66\u4e88\u521d\u59cb\u503c\u624d\u53ef\u4ee5\u63a5\u53d7\u3002<br \/>\n\u4ecb\u7d39\u5b8c\u8b8a\u6578\u7684\u5ba3\u544a\u8207\u8ce6\u503c\u5f8c\u63a5\u4e0b\u4f86\u518d\u4f86\u4ecb\u7d39\u8b8a\u6578\u7684\u578b\u5225\u3002<\/p>\n<h3>\u8b8a\u6578\u578b\u5225<\/h3>\n<p>\u9019\u90e8\u5206\u53ea\u91dd\u5c0d\u5b57\u4e32<code>string<\/code>\u8ddf\u6574\u6578<code>int<\/code>\u4f86\u8aaa\u660e\u3002<\/p>\n<h4>\u5b57\u4e32 string<\/h4>\n<p>\u9019\u5c31\u662f\u5b58\u653e\u6587\u5b57\u7684\u8b8a\u6578\uff0c\u901a\u5e38\u6703\u9047\u5230\u7de8\u78bc\u7684\u554f\u984c\uff0c\u4e0d\u904e\u9019\u90e8\u5206\u6709\u8208\u8da3\u7684\u670b\u53cb\u5011\u518d\u53bb\u67e5\u8cc7\u6599\u4e86\uff0c\u56e0\u70ba\u5b57\u5143\u8f49\u63db\u53ef\u4ee5\u597d\u597d\u591a\u8aaa\u4e0a\u4e00\u7bc7\u3002\u5176\u985e\u578b\u5c31\u662f\u4f7f\u7528\u96d9\u5f15\u865f<code>&quot;<\/code>\u5305\u593e\u8d77\u4f86\u7684\u5c31\u662f\u5b57\u4e32\u4e86\u3002<\/p>\n<h4>\u6574\u6578 int<\/h4>\n<p>\u76f8\u8f03\u65bc\u5b57\u4e32\u4f86\u8aaa\u6574\u6578\u5c31\u7c21\u55ae\u8a31\u591a\uff0c\u56e0\u70ba\u4ed6\u6c92\u6709\u4ec0\u9ebc\u8f49\u63db\u7684\u554f\u984c\uff0c\u4e0d\u904e\u4ed6\u8981\u6ce8\u610f\u7684\u662f\u8a18\u61b6\u9ad4\u6ea2\u4f4d\u7684\u554f\u984c\uff0c\u7c21\u55ae\u8aaa\u660e\u5c31\u662f\u7d2f\u52a0\u5230\u8d85\u904e\u8a18\u61b6\u9ad4\u4e0a\u9650\u7684\u8a71\u6703\u8b8a\u6210\u6700\u5c0f\u503c\uff0c\u8a73\u60c5\u8acb\u898b<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/builtin-types\/integral-numeric-types\" title=\"\u6574\u6578\u7684\u4e0a\u4e0b\u9650\u503c\" rel=\"nofollow noopener\" target=\"_blank\">\u6574\u6578\u7684\u4e0a\u4e0b\u9650\u503c<\/a>\u3002<\/p>\n<h3>\u8b8a\u6578\u7684\u4f7f\u7528<\/h3>\n<p>\u300c\u597d\u4e86\uff0c\u6211\u8b8a\u6578\u8b1b\u5b8c\u4e86\uff0c\u4f60\u4f86\u505a\u500b\u6703\u5c0d\u4eba\u8aaa\u54c8\u56c9\u7684\u7a0b\u5f0f\u5427\u3002\u300d<\/p>\n<p>\u4ecb\u7d39\u5b8c\u8b8a\u6578\u5f8c\u5927\u982d\u5c31\u4ea4\u6d3e\u7d66\u5c0f\u5149\u7b2c\u4e00\u500b\u5de5\u4f5c\uff0c\u5c0f\u5149\u6536\u5230\u6307\u4ee4\u5f8c\u5c31\u958b\u59cb\u5728vscode\u4e0a\u958b\u59cb\u958b\u767c\u4e86\uff0c\u7d50\u679c\u4e0d\u5230\u5e7e\u5206\u9418\u5f8c\u5c0f\u5149\u5c31\u63d0\u4ea4\u7d50\u679c\u7d66\u5927\u982d\u6aa2\u67e5\u3002<\/p>\n<pre><code class=\"language-csharp\">using System;\n\npublic class Program\n{\n    public static void Main()\n    {\n        var name = &quot;\u5c0f\u5149&quot;;\n        Console.WriteLine(&quot;Hello &quot; + name);\n    }\n}\n<\/code><\/pre>\n<p>\u770b\u5b8c\u4e4b\u5f8c\u5927\u982d\u5c0d\u5c0f\u5149\u9019\u9ebc\u8aaa\u3002<br \/>\n\u300c\u5b7a\u5b50\u53ef\u6559\u4e5f\u3002\u300d<\/p>\n<h2>\u5f8c\u8a18<\/h2>\n<p>\u4eca\u5929\u5927\u982d\u4ea4\u6388\u7d66\u5c0f\u5149\u8b8a\u6578\u7684\u6982\u5ff5\uff0c\u4e26\u4e14\u51fa\u500b\u984c\u76ee\u7d66\u5c0f\u5149\u7df4\u7fd2\uff0c\u90a3\u660e\u5929\u5c0f\u5149\u6703\u9047\u5230\u4ec0\u9ebc\u6a23\u7684\u554f\u984c\u5462\uff0c\u656c\u8acb\u671f\u5f85\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a8d\u8b58\u8b8a\u6578 variable \u5728\u6628\u5929\u7684\u6b77\u7a0b\u4e2d\u5c0f\u5149\u5b78\u7fd2\u5230\u5982\u4f55\u900f\u904edotnet cli\u4f86\u7522\u751f\u5c08\u6848\u8ddf\u65b9\u6848\uff0c\u4e26\u4e14\u900f\u904edo &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2021\/09\/18\/variable-int-string\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008D-27-\u8b8a\u6578 variable ? int ? string\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[90,71,92],"class_list":["post-2016","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2021ironman","tag-c","tag-dotnetcore"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=2016"}],"version-history":[{"count":20,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2016\/revisions"}],"predecessor-version":[{"id":2947,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2016\/revisions\/2947"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=2016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=2016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=2016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}