6、使用基元类型而不要使用 FCL 类型

基元类型: int string object uint long ulong 等 ; FCL (Framework Class Library ) System.Int32 等。

一些定义在一些语言中不太一样,比如 long 在C#里表示64位无符号整型,而 C++ 是 32位。

容易引起混淆,从这一方面出发反而不应该使用基元类型。

~~但个人认为注意分辨就行了,还是用基元类型。

internal class ShouldPrimitiveNotFCL
    {
        public void ShouldPrimitive()
        {
            int a = 0;
            string b = "";
            dynamic c = new object();
            object d = new object();
            /*** 使用方便,相当于
             * using int= System.Int32;
             * using string = System.String;
             * */
        }

        public void NotFCL()
        {
            System.Int32 a = new System.Int32();
            String b = "";
            System.Object c = new System.Object();
            System.Object d = new System.Object();
            //生成的 IL 代码一致,但是比较麻烦
        }
    }
原文地址:https://www.cnblogs.com/zhuwansu/p/11128707.html