When does it matter whether you use int versus Int32, or string versus String?

前端 未结 8 650
慢半拍i
慢半拍i 2021-01-19 14:02

In C#, the keywords for built-in types are simply aliases for corresponding types in the System namespace.

Generally, it makes no difference whether yo

相关标签:
8条回答
  • 2021-01-19 14:47

    C# doesn't require you to use one or the other as they are equivalent. It is a personal preference and coding convention. So use the one that seems more readable to you and your team. Just one advice: be consistent: do not use an alias in half of your codebase and the full type name in the second half.

    0 讨论(0)
  • 2021-01-19 14:51

    string is an alias for the type System.String, and int is an alias for System.Int32. Therefore, use to your preference.

    0 讨论(0)
提交回复
热议问题