{"id":8409,"date":"2024-06-10T20:01:03","date_gmt":"2024-06-10T12:01:03","guid":{"rendered":""},"modified":"2024-06-10T20:01:03","modified_gmt":"2024-06-10T12:01:03","slug":"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8409.html","title":{"rendered":"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f"},"content":{"rendered":"

    Unity3D\u63d0\u4f9b\u652f\u6301\u4e09\u79cd\u811a\u672c\u8bed\u8a00\uff0c\u4f46\u662fJscript\u5e76\u975e\u4e00\u6211\u4eec\u6240\u719f\u77e5\u7684\u90a3\u4e2aJscript\uff0c\u6709\u7740\u5f88\u5927\u7684\u4e0d\u540c\uff0c\u6240\u4ee5\u5efa\u8bae\u4f7f\u7528\u4f18\u7f8e\u7684C#\u8bed\u8a00\u6765\u5199\u811a\u672c\uff0c\u4e0b\u9762\u662f\u5fc5\u987b\u638c\u63e1\u7684100\u4e2aC#\u57fa\u672c\u70b9\u3002<\/p>\n

1.C#\u4e2d\u4f7f\u7528\/\/(\u53cc\u659c\u6760)\u6765\u8868\u660e\u672c\u884c\u7684\u5269\u4f59\u90e8\u5206\u4ee3\u8868\u6ce8\u91ca\u3002<\/p>\n

2.C#\u4e2d\u8bed\u53e5\u662f\u6309\u987a\u5e8f\u6267\u884c\u7684\uff0c\u6bcf\u6761\u8bed\u53e5\u4ee5\u5206\u53f7\u7ed3\u5c3e\u3002<\/p>\n

3.C#\u4e2d\u7684\u51fd\u6570\u6267\u884c\u4e00\u7cfb\u5217\u8bed\u53e5\u7684\u884c\u4e3a\uff0c\u79f0\u4e3a\u8bed\u53e5\u5757---\u4e00\u5bf9\u5927\u62ec\u53f7\u4e2d\u5305\u542b0\u6761\u6216\u591a\u6761\u8bed\u53e5\u3002<\/p>\n

4.\u4e00\u4e2a\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u53c2\u6570\u6765\u4ece\u8c03\u7528\u8005\u5904\u63a5\u53d7\u8f93\u5165\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u8fd4\u56de\u7c7b\u578b\u6765\u8f93\u51fa\u6570\u636e\u7ed9\u8c03\u7528\u8005\u3002<\/p>\n

5.Main\u51fd\u6570\u5b9a\u4e49\u4e3a\u6267\u884c\u7a0b\u5e8f\u7684\u9ed8\u8ba4\u5165\u53e3\u70b9\u3002Main\u51fd\u6570\u53ef\u4ee5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u4e5f\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\u7ed9\u6267\u884c\u7a0b\u5e8f\u73af\u5883\u3002Main\u51fd\u6570\u4e5f\u53ef\u4ee5\u4e0d\u5b9a\u4e49\u4efb\u4f55\u53c2\u6570\uff0c\u6216\u8005\u5b9a\u4e49\u4e00\u4e2astring\u6570\u7ec4\u4f5c\u4e3a\u53c2\u6570(\u8be5\u53c2\u6570\u5c06\u7531\u4f20\u9012\u7ed9\u6267\u884c\u7a0b\u5e8f\u7684\u53c2\u6570\u586b\u5145)\u3002<\/p>\n

6.Using\u6307\u4ee4\u7528\u4e8e\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n

7.C#\u4e2d\u7684\u6807\u8bc6\u7b26\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u5f00\u5934\uff0c\u5e76\u4e14\u5927\u5c0f\u5199\u654f\u611f\u3002<\/p>\n

8.\u5173\u952e\u5b57\u662f\u7531\u7f16\u8bd1\u5668\u4fdd\u7559\u7684\u540d\u5b57\uff0c\u4e0d\u80fd\u7528\u4f5c\u6807\u8bc6\u7b26\uff0c\u4e0b\u9762\u662fC#\u7684\u5173\u952e\u5b57\u5217\u8868\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

9.\u5982\u679c\u60f3\u5c06\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\uff0c\u90a3\u4e48\u53ef\u4ee5\u52a0\u4e0a\u524d\u7f00@\u4ee5\u4f7f\u5b83\u5408\u6cd5\uff0c\u4f8b\u5982\uff1aclass @class\u3002\u6ce8\u610f@\u7b26\u53f7\u5e76\u4e0d\u6784\u6210\u6807\u8bc6\u7b26\u7684\u4e00\u90e8\u5206\uff0c\u6240\u4ee5@myVariable\u548cmyVariable\u662f\u76f8\u540c\u7684\u3002<\/p>\n

10.\u4e00\u4e9b\u5173\u952e\u5b57\u662f\u4e0a\u4e0b\u6587\u76f8\u5173\u7684\uff0c\u5b83\u4eec\u4e0d\u7528\u4f7f\u7528\u7b26\u53f7@\u5c31\u80fd\u591f\u88ab\u7528\u4f5c\u6807\u8bc6\u7b26\u3002\u8fd9\u4e9b\u5173\u952e\u5b57\u5982\u4e0b\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

11.C#\u4e2d\u6240\u6709\u7684\u503c\u90fd\u662f\u4e00\u4e2a\u7279\u5b9a\u7c7b\u578b\u7684\u5b9e\u4f8b\uff0c\u4e00\u4e2a\u503c\u7684\u542b\u4e49\uff0c\u4ee5\u53ca\u4e00\u4e2a\u53d8\u91cf\u53ef\u4ee5\u62e5\u6709\u7684\u6240\u6709\u53ef\u80fd\u7684\u503c\uff0c\u662f\u7531\u5b83\u7684\u7c7b\u578b\u51b3\u5b9a\u7684\u3002<\/p>\n

12.\u9884\u5b9a\u4e49\u7c7b\u578b(\u4e5f\u53eb\u5185\u5efa\u7c7b\u578b)\u662f\u88ab\u7f16\u8bd1\u5668\u7279\u522b\u652f\u6301\u7684\u7c7b\u578b\uff0c\u5982int\u3001float\u3001bool\u7b49\u3002<\/p>\n

13.\u81ea\u5b9a\u4e49\u7c7b\u578b\u53ef\u4ee5\u5305\u542b\u6210\u5458\u6570\u636e\u548c\u6210\u5458\u51fd\u6570\u3002\u9700\u8981\u4f7f\u7528new\u8fd0\u7b97\u7b26\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u5b9e\u4f8b\uff0c\u5f53new\u8fd0\u7b97\u7b26\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\u540e\uff0c\u8be5\u5bf9\u8c61\u7684\u6784\u9020\u51fd\u6570\u5c06\u88ab\u8c03\u7528\u3002\u6784\u9020\u51fd\u6570\u7684\u5b9a\u4e49\u7c7b\u4f3c\u4e8e\u666e\u901a\u51fd\u6570\u5b9a\u4e49\uff0c\u9664\u4e86\u51fd\u6570\u540d\u5fc5\u987b\u548c\u7c7b\u540d\u76f8\u540c\u4ee5\u53ca\u53bb\u9664\u4e86\u8fd4\u56de\u7c7b\u578b\u3002<\/p>\n

14.\u5728\u7c7b\u578b\u7684\u5b9e\u4f8b\u4e0a\u64cd\u4f5c\u7684\u6570\u636e\u6210\u5458\u548c\u51fd\u6570\u6210\u5458\u79f0\u4e3a\u5b9e\u4f8b\u6210\u5458\u3002\u800c\u4e0d\u5728\u7c7b\u578b\u7684\u5b9e\u4f8b\u4e0a\uff0c\u4f46\u5728\u7c7b\u578b\u672c\u8eab\u4e0a\u64cd\u4f5c\u7684\u6570\u636e\u6210\u5458\u548c\u51fd\u6570\u6210\u5458\uff0c\u5fc5\u987b\u88ab\u6807\u8bb0\u4e3astatic\u3002<\/p>\n

15.public\u5173\u952e\u5b57\u7528\u4e8e\u663e\u9732\u6210\u5458\u7ed9\u5176\u4ed6\u7c7b\u4f7f\u7528\u3002<\/p>\n

16.C#\u80fd\u591f\u5728\u4e24\u4e2a\u76f8\u517c\u5bb9\u7684\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u8f6c\u6362\u603b\u662f\u6839\u636e\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u503c\u800c\u521b\u5efa\u4e00\u4e2a\u65b0\u503c\u3002\u8f6c\u6362\u53ef\u4ee5\u662f\u9690\u5f0f\u7684\u6216\u8005\u663e\u5f0f\u7684\uff0c\u9690\u5f0f\u7684\u8f6c\u6362\u81ea\u52a8\u53d1\u751f\uff0c\u5982int x = 5; long y = x\u3002\u800c\u663e\u5f0f\u7684\u8f6c\u6362\u9700\u8981\u4e00\u4e2a\u6620\u5c04\uff0c\u5982int x = 5; short y = (short)x\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5f53\u7f16\u8bd1\u5668\u80fd\u591f\u4fdd\u8bc1\u5728\u4e24\u4e2a\u7c7b\u578b\u4e4b\u95f4\u8f6c\u6362\u603b\u662f\u6210\u529f\u7684\uff0c\u4e14\u4e0d\u4e22\u5931\u4efb\u4f55\u4fe1\u606f\uff0c\u90a3\u4e48\u5c31\u5141\u8bb8\u9690\u5f0f\u8f6c\u6362\uff0c\u5426\u5219\u7684\u8bdd\uff0c\u5c31\u5fc5\u987b\u4f7f\u7528\u663e\u5f0f\u8f6c\u6362\u3002<\/p>\n

17.C#\u4e2d\u7684\u7c7b\u578b\u53ef\u4ee5\u5206\u4e3a\u503c\u7c7b\u578b\u548c\u5f15\u7528\u7c7b\u578b\u3002\u503c\u7c7b\u578b\u5305\u62ec\u4e86\u5927\u591a\u6570\u5185\u7f6e\u7c7b\u578b(\u6240\u6709\u7684\u6570\u503c\u7c7b\u578b(int, float\u7b49)\uff0cchar\u7c7b\u578b\uff0cbool\u7c7b\u578b\u4ee5\u53castruct\u4e0eenum\u7c7b\u578b)\uff0c\u5f15\u7528\u7c7b\u578b\u5305\u62ec\u4e86\u6240\u6709\u7684class\uff0carray\uff0cdelegate\u4e0einterface\u7c7b\u578b\u3002<\/p>\n

18.\u4e00\u4e2a\u503c\u7c7b\u578b\u7684\u53d8\u91cf\u6216\u5e38\u91cf\u5305\u542b\u7684\u5185\u5bb9\u4ec5\u4ec5\u662f\u4e00\u4e2a\u503c\uff0c\u5bf9\u4e00\u4e2a\u503c\u7c7b\u578b\u7684\u5b9e\u4f8b\u8fdb\u884c\u8d4b\u503c\u603b\u662f\u4f1a\u62f7\u8d1d\u5b9e\u9645\u6570\u636e\u5230\u8be5\u5b9e\u4f8b\u3002\u5f15\u7528\u7c7b\u578b\u7684\u53d8\u91cf\u6216\u5e38\u91cf\u5305\u542b\u7684\u5185\u5bb9\u662f\u5bf9\u4e00\u4e2a\u62e5\u6709\u5b9e\u9645\u6570\u636e\u7684\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u5bf9\u4e00\u4e2a\u5f15\u7528\u7c7b\u578b\u7684\u5b9e\u4f8b\u8fdb\u884c\u8d4b\u503c\u603b\u662f\u4f1a\u62f7\u8d1d\u5f15\u7528\uff0c\u800c\u4e0d\u4f1a\u62f7\u8d1d\u62e5\u6709\u5b9e\u9645\u6570\u636e\u7684\u5bf9\u8c61\u5b9e\u4f8b\uff0c\u8fd9\u5c31\u5141\u8bb8\u591a\u4e2a\u53d8\u91cf\u5f15\u7528\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n

19.\u4e00\u4e2a\u5f15\u7528\u7c7b\u578b\u7684\u5b9e\u4f8b\u53ef\u4ee5\u88ab\u8bbe\u7f6e\u4e3anull\uff0c\u4ee5\u8868\u660e\u6ca1\u6709\u5f15\u7528\u4efb\u4f55\u5bf9\u8c61\uff0c\u4f7f\u7528\u4e00\u4e2a\u4e3anull\u7684\u5b9e\u4f8b\u7684\u6210\u5458\u5c06\u4ea7\u751f\u4e00\u4e2a\u8fd0\u884c\u65f6\u9519\u8bef\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u4e00\u4e2a\u503c\u7c7b\u578b\u7684\u5b9e\u4f8b\u4e0d\u80fd\u88ab\u8bbe\u7f6e\u4e3anull\u3002<\/p>\n

20.C#\u4e2d\u7684\u9884\u5b9a\u4e49\u7c7b\u578b\u5206\u7c7b\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

21.C#\u9884\u5b9a\u4e49\u7684\u6570\u5b57\u7c7b\u578b\u5982\u4e0b\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

22.\u6574\u578b\u53ef\u4ee5\u4f7f\u752810\u8fdb\u5236\u621616\u8fdb\u5236\u6807\u8bb0\u6cd5\uff0c16\u8fdb\u5236\u6807\u8bb0\u6cd5\u9700\u8981\u52a00x\u524d\u7f00\uff0c\u59820x7F\u3002\u5b9e\u6570\u53ef\u4ee5\u752810\u8fdb\u5236\u6216\u6307\u6570\u6807\u8bb0\u6cd5\uff0c\u59821e06\u3002<\/p>\n

23.\u6d6e\u70b9\u6570\u8f6c\u6362\u4e3a\u6574\u6570\u5c06\u4e22\u5f03\u5c0f\u6570\u90e8\u5206\uff0c\u5982\u679c\u60f3\u8981\u8fdb\u884c\u56db\u820d\u4e94\u5165\u7684\u8f6c\u6362\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528System.Convert\u7c7b\u3002<\/p>\n

24.\u9700\u8981\u6ce8\u610f\u4ece1\u4e2a\u5f88\u5927\u7684\u6574\u6570\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u65f6\u53ef\u80fd\u4f1a\u4e22\u5931\u7cbe\u5ea6\uff0c\u5982int x = ; float f = x; \/\/ \u6b64\u65f6f = \u3002<\/p>\n

25.\u7b97\u6570\u8fd0\u7b97\u7b26(+,-,*,\/,%)\u53ef\u4ee5\u7528\u4e8e\u6240\u6709\u7684\u6570\u503c\u7c7b\u578b(\u9664\u4e868\u4f4d\u548c16\u4f4d\u7684\u6574\u6570\u7c7b\u578b)\u3002<\/p>\n

26.\u81ea\u589e\uff0c\u81ea\u51cf\u8fd0\u7b97\u7b26\u7528\u4e8e\u4f7f\u6570\u503c\u7c7b\u578b\u7684\u53d8\u91cf\u52a01\u6216\u51cf1\u3002\u8fd0\u7b97\u7b26\u53ef\u4ee5\u653e\u5728\u53d8\u91cf\u524d(++x)\u6216\u8005\u53d8\u91cf\u540e(x++)\uff0c\u53d6\u51b3\u4e8e\u60f3\u5728\u8868\u8fbe\u5f0f\u8ba1\u7b97\u4e4b\u524d\u8fd8\u662f\u4e4b\u540e\u66f4\u65b0\u53d8\u91cf\u7684\u503c\u3002<\/p>\n

27.\u6574\u6570\u9664\u6cd5\u603b\u662f\u4f1a\u4e22\u5f03\u4f59\u6570\u3002\u5982\u679c\u9664\u4ee5\u4e00\u4e2a\u503c\u4e3a0\u7684\u53d8\u91cf\u5c06\u4ea7\u751f\u4e00\u4e2a\u8fd0\u884c\u65f6\u9519\u8bef(DivideByZeroException)\uff0c\u9664\u4ee5\u5b57\u9762\u503c0\u5c06\u4ea7\u751f\u7f16\u8bd1\u9519\u8bef\u3002<\/p>\n

28.\u5728\u8fd0\u884c\u65f6\uff0c\u6574\u6570\u7c7b\u578b\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\u53ef\u80fd\u4f1a\u9020\u6210\u6ea2\u51fa\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e0d\u4f1a\u6709\u5f02\u5e38\u88ab\u629b\u51fa\u3002C#\u6587\u6863\u8868\u660e\u5bf9\u4e8e\u6ea2\u51fa\u7ed3\u679c\u662f\u4e0d\u53ef\u9884\u6599\u7684\uff0c\u4f46\u662fCommon Language Runtime(CLR)\u603b\u662f\u4ea7\u751f\u4e00\u4e2awraparound\u884c\u4e3a\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5c06\u6700\u5c0f\u7684int\u503c\u51cf1\u7684\u7ed3\u679c\u662f\u6700\u5927\u7684int\u503c\uff0c\u5982int x = int.MinValue; x--; \/\/ \u6b64\u65f6x = int.MaxValue\u3002<\/p>\n

29.checked\u8fd0\u7b97\u7b26\u901a\u77e5\u8fd0\u884c\u65f6\u5f53\u6ea2\u51fa\u65f6\u629b\u51fa\u4e00\u4e2aOverflowException\u5f02\u5e38\uff0cchecked\u8fd0\u7b97\u7b26\u53ef\u4ee5\u7528\u4e8e++, --, -(\u4e00\u5143), +, -, *, \/\u4ee5\u53ca\u6574\u6570\u7c7b\u578b\u4e4b\u95f4\u7684\u663e\u793a\u8f6c\u6362\u3002checked\u8fd0\u7b97\u7b26\u53ef\u4ee5\u7528\u4e8e\u4e00\u4e2a\u8868\u8fbe\u5f0f\u6216\u8005\u4e00\u4e2a\u8bed\u53e5\u5757\uff0c\u5982\uff1a<\/p>\n

\n
\n <\/span>\n <\/div>\n
1<\/span> int<\/span> a = <\/span>; 2<\/span> int<\/span> b = <\/span>; 3<\/span> int<\/span> c = checked<\/span>( a * b ); \/\/<\/span> \u7528\u4e8e\u8868\u8fbe\u5f0f<\/span> <\/span>4<\/span> 5<\/span> checked<\/span> 6<\/span> { 7<\/span> c = a * b; \/\/<\/span> \u7528\u4e8e\u8bed\u53e5\u5757<\/span> <\/span>8<\/span> }<\/pre>\n
\n <\/span>\n <\/div>\n<\/div>\n

\u53ef\u4ee5\u4f7f\u7528\/checked[+\/-]\u7f16\u8bd1\u9009\u9879\u6765\u68c0\u6d4b\/\u4e0d\u68c0\u6d4b\u7a0b\u5e8f\u4e2d\u6240\u6709\u53d1\u751f\u7684\u6ea2\u51fa\uff0c\u5982\u679c\u4f7f\u7528\u4e86\/checked+\u6765\u68c0\u6d4b\u7a0b\u5e8f\u4e2d\u6240\u6709\u53d1\u751f\u7684\u6ea2\u51fa\uff0c\u800c\u5bf9\u4e8e\u67d0\u4e9b\u7279\u5b9a\u7684\u8868\u8fbe\u5f0f\u6216\u8bed\u53e5\u5757\u53c8\u4e0d\u60f3\u4f7f\u7528\u68c0\u6d4b\u529f\u80fd\uff0c\u90a3\u4e48\u53ef\u4ee5\u50cfchecked\u8fd0\u7b97\u7b26\u4e00\u6837\u4f7f\u7528unchecked\u8fd0\u7b97\u7b26\u6765\u5173\u95ed\u68c0\u6d4b\u3002<\/p>\n

30.C#\u63d0\u4f9b\u4e86\u4e0b\u9762\u8fd9\u4e9b\u4f4d\u8fd0\u7b97\u7b26\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

31.8\u4f4d\u548c16\u4f4d\u7684\u6574\u578b\u5305\u62ec\u4e86byte, sbyte, short\u548cushort\uff0c\u8fd9\u4e9b\u7c7b\u578b\u81ea\u8eab\u6ca1\u6709\u7b97\u6570\u8fd0\u7b97\u7b26\uff0c\u6240\u4ee5C#\u5728\u9700\u8981\u65f6\u4f1a\u5c06\u5b83\u4eec\u8f6c\u6362\u4e3a\u66f4\u5927\u7684\u7c7b\u578b\uff0c\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4\u5982\u679c\u63a5\u6536\u8fd0\u7b97\u7ed3\u679c\u7684\u662f\u4e00\u4e2a\u8f83\u5c0f\u7684\u6574\u578b\u65f6\uff0c\u4f1a\u53d1\u751f\u7f16\u8bd1\u9519\u8bef\uff0c\u5982short x = 1, y = 1; short z = x + y; \/\/ \u6b64\u5904\u7f16\u8bd1\u9519\u8bef\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e3a\u4e86\u4f7f\u52a0\u6cd5\u80fd\u591f\u6267\u884c\uff0cx, y\u4f1a\u88ab\u9690\u5f0f\u7684\u8f6c\u6362\u4e3aint\uff0c\u8fd9\u610f\u5473\u7740\u7ed3\u679c\u4e5f\u662fint\uff0c\u800cint\u4e0d\u80fd\u88ab\u9690\u5f0f\u7684\u8f6c\u6362\u4e3ashort(\u56e0\u4e3a\u4f1a\u5bfc\u81f4\u6570\u636e\u4e22\u5931)\uff0c\u6240\u4ee5\uff0c\u4e3a\u4e86\u4f7f\u7f16\u8bd1\u901a\u8fc7\uff0c\u6211\u4eec\u9700\u8981\u52a0\u4e0a\u663e\u5f0f\u8f6c\u6362\uff0cshort z = (short)(x + y);<\/p>\n

32.float\u548cdouble\u7c7b\u6709\u4e00\u4e9b\u5e38\u91cf\u7528\u4e8eNaN(Not a Number), +\u221e, -\u221e, MaxValue, MinValue\u548cEpsilon\u3002\u5f53\u53d1\u751f\u96640\u65f6\u5c06\u5bfc\u81f4\u7ed3\u679c\u4e3a\u65e0\u7a77\u503c\uff0c\u5982\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f\u3002\u5f53\u53d1\u751f0\u96640\u6216\u8005\u65e0\u7a77\u51cf\u65e0\u7a77\u65f6\u5c06\u5bfc\u81f4\u7ed3\u679c\u4e3aNaN\uff0c\u5982<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f\u3002\u5f53\u4f7f\u7528==\u65f6\uff0c\u4e00\u4e2aNaN\u503c\u6c38\u8fdc\u4e0d\u4f1a\u7b49\u4e8e\u53e6\u4e00\u4e2a\u503c\uff0c\u5373\u4f7f\u662f\u53e6\u4e00\u4e2aNaN\u503c\uff0c\u6240\u4ee5\u5982\u679c\u8981\u6d4b\u8bd5\u4e00\u4e2a\u503c\u662f\u5426\u4e3aNaN\uff0c\u5fc5\u987b\u4f7f\u7528float.IsNaN\u6216\u8005double.IsNaN\u51fd\u6570\u3002\u5f53\u4f7f\u7528Object.Equals\u51fd\u6570\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5224\u65ad\u4e24\u4e2aNaN\u503c\u662f\u5426\u76f8\u7b49\uff0c\u5982object.Equals (0.0\/0.0, double.NaN) \/\/ true\u3002<\/p>\n

33.float\u7c7b\u578b\u9002\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\uff0c\u800cdecimal\u7c7b\u578b\u9002\u7528\u4e8e\u91d1\u878d\u8ba1\u7b97\u6216\u8005\u8868\u793a\u90a3\u4e9b\u4eba\u4e3a\u7684\u503c\uff0c\u4e0b\u9762\u662fdouble\u7c7b\u578b\u4e0edecimal\u7c7b\u578b\u7684\u533a\u522b\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f<\/p>\n

34.\u7531\u4e8efloat\u548cdouble\u7c7b\u578b\u7684\u6570\u503c\u5728\u5185\u90e8\u662f\u4ee52\u4e3a\u57fa\u8868\u793a\u7684\uff0c\u6240\u4ee5\u8bb8\u591a\u4ee510\u4e3a\u57fa\u7684\u5c0f\u6570\u90e8\u5206\u5b57\u9762\u503c\u65e0\u6cd5\u88ab\u7cbe\u786e\u7684\u8868\u793a\uff0c\u5982<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48float\u548cdouble\u7c7b\u578b\u4e0d\u9002\u7528\u4e8e\u91d1\u878d\u8ba1\u7b97\u7684\u539f\u56e0\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u7531\u4e8edecimal\u7c7b\u578b\u7684\u6570\u503c\u662f\u4ee510\u4e3a\u57fa\u8868\u793a\u7684\uff0c\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\u4e0d\u4f1a\u51fa\u73b0\u3002<\/p>\n

35.C#\u7684bool\u7c7b\u578b\u662f\u4e00\u4e2a\u53ef\u4ee5\u88ab\u6307\u5b9a\u4e3atrue\u6216\u8005false\u7684\u903b\u8f91\u503c\u3002\u5c3d\u7ba1\u4e00\u4e2abool\u7c7b\u578b\u4ec5\u9700\u89811\u4f4d\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u4f46\u662f\u8fd0\u884c\u65f6\u5c06\u4f7f\u75281\u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u56e0\u4e3a\u8fd9\u662f\u8fd0\u884c\u65f6\u548c\u5904\u7406\u5668\u53ef\u4ee5\u6709\u6548\u5de5\u4f5c\u7684\u6700\u5c0f\u5355\u4f4d\u3002\u6240\u4ee5\u4e3a\u4e86\u907f\u514d\u7a7a\u95f4\u4e0a\u7684\u6d6a\u8d39\uff0cC#\u63d0\u4f9b\u4e86\u4e00\u4e2aBitArray\u7c7b\uff0c\u8be5\u7c7b\u4f4d\u4e8eSystem.Collections\u547d\u540d\u7a7a\u95f4\u4e0b\uff0c\u65e8\u5728\u53ea\u4f7f\u75281\u4f4d\u5b58\u50a8\u7a7a\u95f4\u8868\u793a\u6bcf\u4e2abool\u7c7b\u578b\u7684\u503c\u3002<\/p>\n

36.\u5bf9\u4e8e\u5f15\u7528\u7c7b\u578b\uff0c\u662f\u5426\u76f8\u7b49\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f\u53d6\u51b3\u4e8e\u6240\u5f15\u7528\u7684\u5bf9\u8c61\u662f\u5426\u76f8\u540c\uff0c\u800c\u4e0d\u662f\u5bf9\u8c61\u5185\u90e8\u7684\u5b9e\u9645\u6570\u636e\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u5bf9\u8c61\u7684\u4e24\u4e2a\u62e5\u6709\u76f8\u540c\u6570\u636e\u7684\u5b9e\u4f8b\u88ab\u8ba4\u4e3a\u662f\u4e0d\u76f8\u7b49\u7684\uff0c\u9664\u975e\u8be5\u5bf9\u8c61\u6240\u5c5e\u7684\u7c7b\u578b\u91cd\u8f7d\u4e86==\u8fd0\u7b97\u7b26\u4ee5\u8fbe\u5230\u4f7f\u4ed6\u4eec\u76f8\u7b49\u7684\u6548\u679c\u3002<\/p>\n

37.\u76f8\u7b49\u548c\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff0c==, !=, <, >, <=, >=\uff0c\u53ef\u4ee5\u7528\u4e8e\u6240\u6709\u7684\u6570\u503c\u7c7b\u578b\uff0c\u4f46\u662f\u7528\u4e8e\u5b9e\u6570\u65f6\u9700\u8981\u8c28\u614e\u5c0f\u5fc3(\u53c2\u89c134)\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u4e5f\u53ef\u4ee5\u7528\u4e8eenum(\u679a\u4e3e)\u7c7b\u578b\u6210\u5458\uff0c\u6bd4\u8f83\u7684\u662f\u4ed6\u4eec\u4ee3\u8868\u7684\u6574\u578b\u6570\u503c\u3002<\/p>\n

38.&&\u548c||\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u6761\u4ef6\u4e0e\u548c\u6761\u4ef6\u6216\uff0c\u4ed6\u4eec\u662f\u77ed\u8def\u8fd0\u7b97\u7b26\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u524d\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e0d\u6ee1\u8db3\u65f6\uff0c\u540e\u7eed\u8868\u8fbe\u5f0f\u5c06\u4e0d\u518d\u8ba1\u7b97\uff0c\u5982if ( a && b )\uff0c\u5982\u679c\u8868\u8fbe\u5f0fa\u4e3a\u5047\uff0c\u90a3\u4e48\u8868\u8fbe\u5f0fb\u5c06\u4e0d\u4f1a\u8ba1\u7b97\uff0c\u8fd9\u662f\u5341\u5206\u6709\u7528\u7684\uff0c\u4f8b\u5982\uff1aif (sb != null && sb.Length > 0)\uff0c\u53ef\u4ee5\u907f\u514d\u629b\u51faNullReferenceException\u5f02\u5e38\u3002&\u548c|\u8fd0\u7b97\u7b26\u4e5f\u53ef\u7528\u4e8e\u6d4b\u8bd5\u6761\u4ef6\u4e0e\u548c\u6761\u4ef6\u6216\uff0c\u4f46\u662f\u4ed6\u4eec\u4e0d\u662f\u77ed\u8def\u8fd0\u7b97\u7b26\uff0c\u6240\u4ee5\uff0c\u4e00\u822c\u5f88\u5c11\u7528\u4e8e\u6761\u4ef6\u6d4b\u8bd5\u3002\u8fd8\u6709\u4e00\u4e2a\u4e09\u76ee\u8fd0\u7b97\u7b26\uff0c\u5f62\u5f0f\u5982q ? a : b\uff0c\u5f53q\u4e3a\u771f\u65f6\uff0ca\u5c06\u88ab\u8ba1\u7b97\uff0c\u5426\u5219b\u5c06\u88ab\u8ba1\u7b97\u3002<\/p>\n

39.C#\u7684char\u7c7b\u578b\u4ee3\u8868\u4e00\u4e2aUnicode\u5b57\u7b26\uff0c\u5360\u75282\u4e2a\u5b57\u8282\u3002\u4e00\u4e2achar\u7684\u5b57\u9762\u8868\u793a\u5728\u4e00\u4e2a\u5355\u5f15\u53f7\u4e2d\uff0c\u5982char c = 'A';\u8f6c\u4e49\u5b57\u7b26\u7528\u6765\u8868\u793a\u90a3\u4e9b\u4e0d\u80fd\u663e\u793a\u7684\u5b57\u7b26\uff0c\u4e00\u4e2a\u8f6c\u4e49\u5b57\u7b26\u662f\u4e00\u4e2a\u53cd\u659c\u6760\u7d27\u8ddf\u4e00\u4e2a\u5b57\u7b26\uff0c\u5177\u6709\u7279\u5b9a\u7684\u542b\u4e49\uff0c\u8f6c\u4e49\u5b57\u7b26\u8868\u5982\u4e0b\uff1a<\/p>\n

\"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620f\u3002\\u(\u6216\\x)\u8f6c\u4e49\u5b57\u7b26\u5141\u8bb8\u4f60\u901a\u8fc7\u4f7f\u75284\u4f4d16\u8fdb\u5236\u6765\u6307\u5b9a\u4efb\u610f\u7684Unicode\u5b57\u7b26\uff0c\u5982char newLine = '\\u000A';<\/p>\n

40.\u5f53\u4e00\u4e2a\u6570\u503c\u7c7b\u578b\u53ef\u4ee5\u5bb9\u7eb3\u4e00\u4e2aunsigned short\u7c7b\u578b\u7684\u503c\u65f6\uff0c\u4ecechar\u5230\u8be5\u6570\u503c\u7c7b\u578b\u5c31\u53ef\u4ee5\u9690\u5f0f\u8f6c\u6362\u3002\u5426\u5219\u7684\u8bdd\uff0c\u5c31\u9700\u8981\u663e\u793a\u8f6c\u6362\u3002<\/p>\n

41.string\u7c7b\u578b\u8868\u793a\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684Unicode\u5b57\u7b26\u5e8f\u5217\u3002\u4e00\u4e2astring\u7684\u5b57\u9762\u8868\u793a\u5728\u4e00\u4e2a\u53cc\u5f15\u53f7\u4e2d\uff0c\u5982string s = \"hello\";\u5c3d\u7ba1string\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u800c\u4e0d\u662f\u503c\u7c7b\u578b\uff0c\u4f46\u662f\u5b83\u7684==\u8fd0\u7b97\u7b26\u5374\u9075\u5faa\u503c\u7c7b\u578b\u7684\u6bd4\u8f83\u8bed\u4e49\uff0c\u5982string a = \"test\", b = \"test\"; Console.Write (a == b); \/\/ True\u3002\u8f6c\u4e49\u5b57\u7b26\u540c\u6837\u4e5f\u53ef\u4ee5\u7528\u5728string\u7c7b\u578b\u4e2d\uff0c\u5982string a = \"\\\\\\\\server\\\\fileshare\";C#\u8fd8\u63d0\u4f9b\u9010\u5b57\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u4ee5@\u5f00\u5934\u5e76\u4e14\u4e0d\u518d\u89e3\u6790\u8f6c\u4e49\u5b57\u7b26\uff0c\u5982string b = @\"\\\\server\\fileshare\";\u548c\u4e0a\u9762\u7684\u5b57\u7b26\u4e32a\u662f\u7b49\u4ef7\u7684\u3002<\/p>\n

42.+\u8fd0\u7b97\u7b26\u7528\u4e8e\u8fde\u63a5\u4e24\u4e2a\u5b57\u7b26\u4e32\uff0c\u5982string a = \"s\" + \"w\";\u53ef\u80fd\u67d0\u4e2a\u64cd\u4f5c\u6570\u4e0d\u662fstring\u7c7b\u578b\uff0c\u90a3\u4e48\u8be5\u64cd\u4f5c\u6570\u7c7b\u578b\u7684ToString\u51fd\u6570\u5c06\u88ab\u8c03\u7528\uff0c\u5982string a = \"s\" + 5;\u7b49\u4ef7\u4e8estring a = \"s\" + 5.ToString();\u56e0\u4e3astring\u7c7b\u578b\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u6240\u4ee5\u591a\u6b21\u7684\u4f7f\u7528+\u8fd0\u7b97\u7b26\u6784\u5efa\u4e00\u4e2a\u65b0\u7684string\u662f\u5341\u5206\u4f4e\u6548\u7684\u3002\u53d6\u800c\u4ee3\u4e4b\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528System.Text.StringBuilder\u7c7b\u578b\uff0c\u8fd9\u4ee3\u8868\u4e86\u4e00\u4e2a\u53ef\u53d8\u7684\u5b57\u7b26\u4e32\uff0c\u4ee5\u53ca\u62e5\u6709\u53ef\u4ee5\u9ad8\u6548\u7684\u6dfb\u52a0\uff0c\u5220\u9664\uff0c\u63d2\u5165\uff0c\u66ff\u6362\u5b50\u4e32\u7684\u65b9\u6cd5\u3002<\/p>\n

43.string\u7c7b\u578b\u4e0d\u652f\u6301<\u548c>\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u6bd4\u8f83\u64cd\u4f5c\uff0c\u5fc5\u987b\u4f7f\u7528string\u7c7b\u578b\u7684CompareTo\u51fd\u6570\u3002<\/p>\n

44.\u5b57\u7b26\u4e32\u7684\u7d22\u5f15\u8fd4\u56de\u7279\u5b9a\u4f4d\u7f6e\u4e0a\u7684\u5b57\u7b26\uff0c\u5982Console.Write (\"word\"[2]); \/\/ r\u3002<\/p>\n

45.\u5207\u8bb0\uff1astring\u7c7b\u578b\u4ee3\u8868\u7684\u5b57\u7b26\u4e32\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u6240\u6709\u64cd\u4f5c\u5b57\u7b26\u4e32\u7684\u51fd\u6570\u5c06\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\uff0c\u539f\u6765\u7684\u5b57\u7b26\u4e32\u4e0d\u4f1a\u88ab\u6539\u53d8\u3002<\/p>\n

46.\u4e00\u4e2a\u6570\u7ec4(Array)\u4ee3\u8868\u4e00\u4e2a\u7279\u5b9a\u7c7b\u578b\u7684\u56fa\u5b9a\u6570\u91cf\u7684\u5143\u7d20\u3002\u4e00\u65e6\u6570\u7ec4\u88ab\u521b\u5efa\uff0c\u5b83\u7684\u957f\u5ea6\u5c31\u4e0d\u80fd\u88ab\u6539\u53d8\u4e86\u3002\u6570\u7ec4\u5143\u7d20\u603b\u662f\u88ab\u5b58\u50a8\u5728\u8fde\u7eed\u7684\u5185\u5b58\u5757\u4e2d\uff0c\u4ee5\u4f9b\u9ad8\u6548\u7684\u5b58\u53d6\u3002\u4e00\u4e2a\u6570\u7ec4\u4ee5\u5143\u7d20\u7c7b\u578b\u7d27\u8ddf\u65b9\u62ec\u53f7\u6765\u8868\u793a\uff0c\u5982char[] vowels = new char[5]; \u65b9\u62ec\u53f7\u4e5f\u7528\u4e8e\u6570\u7ec4\u7d22\u5f15\uff0c\u5b58\u53d6\u4e00\u4e2a\u7279\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20\uff0c\u5982vowels[0] = 'a'; \u5728\u8fd0\u884c\u65f6\u6240\u6709\u7684\u6570\u7ec4\u7d22\u5f15\u90fd\u4f1a\u8fdb\u884c\u8303\u56f4\u68c0\u6d4b\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u4e00\u4e2a\u65e0\u6548\u7684\u7d22\u5f15\uff0c\u90a3\u4e48\u5c06\u629b\u51fa\u4e00\u4e2aIndexOutOfRangeException\u5f02\u5e38\u3002<\/p>\n

47.\u6570\u7ec4\u7684\u521d\u59cb\u5316\u8868\u8fbe\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u7684\u540c\u65f6\u58f0\u660e\u548c\u8d4b\u503c\u4e00\u4e2a\u6570\u7ec4\uff0c\u5982char[] vowels = new char[] {'a','e','i','o','u'}; \u6216\u8005\u66f4\u7b80\u5355\u7684\u65b9\u5f0fchar[] vowels = {'a','e','i','o','u'}; \u53ef\u4ee5\u4f7f\u7528for\u5faa\u73af\u6765\u904d\u5386\u4e00\u4e2a\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u540c\u65f6\uff0c\u7531\u4e8e\u6570\u7ec4\u603b\u662f\u5b9e\u73b0\u4e86IEnumerable<T>\uff0c\u6240\u4ee5\u4e5f\u80fd\u591f\u4f7f\u7528foreach\u6765\u679a\u4e3e\u6570\u7ec4\u6210\u5458\uff1a<\/p>\n

\n
\n <\/span>\n <\/div>\n
 1<\/span> char<\/span>[] vowels = { \n  '<\/span>a<\/span>'<\/span>,'<\/span>e<\/span>'<\/span>,'<\/span>i<\/span>'<\/span>,'<\/span>o<\/span>'<\/span>,'<\/span>u<\/span>'<\/span>};  2<\/span>  3<\/span> for<\/span> (int<\/span> i = 0<\/span>; i < vowels.Length; i++)  4<\/span> {  5<\/span> Console.Write (vowels[i]);  6<\/span> }  7<\/span>  8<\/span> foreach<\/span> (char<\/span> c in<\/span> vowels)  9<\/span> { 10<\/span> Console.Write (c); 11<\/span> }<\/pre>\n
\n <\/span>\n <\/div>\n<\/div>\n

48.\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u603b\u662f\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u503c\u6765\u9884\u521d\u59cb\u5316\u6bcf\u4e2a\u5143\u7d20\uff0c\u4e00\u4e2a\u7c7b\u578b\u7684\u9ed8\u8ba4\u503c\u5c31\u662f\u5728\u5185\u5b58\u4e2d\u6bcf\u4e00\u4f4d\u90fd\u662f0\uff0c\u5bf9\u4e8e\u503c\u7c7b\u578b\u6765\u8bf4\uff0c\u5c31\u662f0\uff0c\u5bf9\u4e8e\u5f15\u7528\u7c7b\u578b\u6765\u8bf4\uff0c\u5c31\u662fnull\u3002\u65e0\u8bba\u5143\u7d20\u7c7b\u578b\u662f\u4ec0\u4e48\uff0c\u6570\u7ec4\u81ea\u8eab\u603b\u662f\u5f15\u7528\u7c7b\u578b\u7684\u3002<\/p>\n

49.\u591a\u7ef4\u6570\u7ec4\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a\u77e9\u5f62\u6570\u7ec4(Rectangular arrays)\u548c\u4e0d\u89c4\u5219\u6570\u7ec4(Jagged arrays)\u3002\u77e9\u5f62\u6570\u7ec4\u58f0\u660e\u65f6\u4f7f\u7528\u9017\u53f7\u6765\u5206\u5272\u6bcf\u4e00\u7ef4\uff0c\u5982int[,] matrix = new int [3, 3]; \u4e00\u4e2a\u77e9\u5f62\u6570\u7ec4\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u521d\u59cb\u5316\uff1a<\/p>\n

\n
\n
\n
\n ?\n <\/div>\n\n\n\n
\n
\n 1\n <\/div>\n
\n 2\n <\/div>\n
\n 3\n <\/div>\n
\n 4\n <\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"unity3d\u7528\u4ec0\u4e48\u8bed\u8a00_UNITY\u6e38\u620fUnity3D\u63d0\u4f9b\u652f\u6301\u4e09\u79cd\u811a\u672c\u8bed\u8a00\uff0c\u4f46\u662fJscript\u5e76\u975e\u4e00\u6211\u4eec\u6240\u719f\u77e5\u7684\u90a3\u4e2aJscript\uff0c\u6709\u7740\u5f88\u5927\u7684\u4e0d\u540c\uff0c\u6240...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8409"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8409"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8409\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}