\u6211\u4eec\u5df2\u7ecf\u5728\u524d\u9762\u7684\u7ae0\u8282\u4e2d\u8bb2\u89e3\u4e86 \u6761\u4ef6\u8fd0\u7b97\u7b26 ? :\uff0c\u53ef\u4ee5\u7528\u6765\u66ff\u4ee3 if...else \u8bed\u53e5\u3002\u5b83\u7684\u4e00\u822c\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n
Exp1 ? Exp2 : Exp3;<\/pre>\n\u5176\u4e2d\uff0cExp1\u3001Exp2 \u548c Exp3 \u662f\u8868\u8fbe\u5f0f\u3002\u8bf7\u6ce8\u610f\uff0c\u5192\u53f7\u7684\u4f7f\u7528\u548c\u4f4d\u7f6e\u3002<\/p>\n
? \u8868\u8fbe\u5f0f\u7684\u503c\u662f\u7531 Exp1 \u51b3\u5b9a\u7684\u3002\u5982\u679c Exp1 \u4e3a\u771f\uff0c\u5219\u8ba1\u7b97 Exp2 \u7684\u503c\uff0c\u7ed3\u679c\u5373\u4e3a\u6574\u4e2a ? \u8868\u8fbe\u5f0f\u7684\u503c\u3002\u5982\u679c Exp1 \u4e3a\u5047\uff0c\u5219\u8ba1\u7b97 Exp3 \u7684\u503c\uff0c\u7ed3\u679c\u5373\u4e3a\u6574\u4e2a ? \u8868\u8fbe\u5f0f\u7684\u503c\u3002
\n?: \u4e3e\u4f8b \u4e0b\u9762\u662f\u9636\u4e58\u7684\u9012\u5f52\u7b97\u6cd5\uff0c\u5176\u4e2d\u5224\u65ad\u6761\u4ef6\u5982\u679c num>0 \u5219\u8fd4\u56de num *Jc(num - 1)\uff0c\u5426\u5219\u8fd4\u56de 1\u3002<\/p>\n
using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nnamespace jiecheng\r\n{\r\n class jiecheng\r\n {\r\n public int Jc(int num)\r\n {\r\n \r\n return num > 0 ? num *Jc(num - 1):1; \/\/\u5982\u679cnum>0\u5219\u8fd4\u56denum *Jc(num - 1)\uff0c\u5426\u5219\u8fd4\u56de1\r\n }\r\n }\r\n\r\n class excutejiecheng\r\n \r\n {\r\n static void Main(string[] args)\r\n {\r\n jiecheng n = new jiecheng();\r\n int result = n.Jc(Convert.ToInt16(Console.ReadLine()));\r\n Console.WriteLine(\"result is {0}\",result);\r\n Console.ReadKey();\r\n }\r\n }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"\u5224\u65ad\u7ed3\u6784\u8981\u6c42\u7a0b\u5e8f\u5458\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u8981\u8bc4\u4f30\u6216\u6d4b\u8bd5\u7684\u6761\u4ef6\uff0c\u4ee5\u53ca\u6761\u4ef6\u4e3a\u771f\u65f6\u8981\u6267\u884c\u7684\u8bed\u53e5\uff08\u5fc5\u9700\u7684\uff09\u548c\u6761\u4ef6\u4e3a\u5047\u65f6\u8981\u6267\u884c\u7684\u8bed […]<\/p>\n","protected":false},"author":321,"featured_media":236229,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-236227","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/236227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=236227"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/236227\/revisions"}],"predecessor-version":[{"id":236232,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/236227\/revisions\/236232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/236229"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=236227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=236227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=236227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}