Skip to content

Commit

Permalink
Changed guidance to prefer int.Parse() over Int32.Parse(). (#223)
Browse files Browse the repository at this point in the history
Co-authored-by: bart-degreed <bart@degreed.com>
  • Loading branch information
bkoelman and bart-degreed authored Mar 6, 2021
1 parent a97d56d commit 1eedd41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _rules/2201.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ rule_category: dotnet-framework-usage
title: Use C# type aliases instead of the types from the `System` namespace
severity: 1
---
For instance, use `object` instead of `Object`, `string` instead of `String`, and `int` instead of `Int32`. These aliases have been introduced to make the primitive types first class citizens of the C# language, so use them accordingly.
For instance, use `object` instead of `Object`, `string` instead of `String`, and `int` instead of `Int32`. These aliases have been introduced to make the primitive types first class citizens of the C# language, so use them accordingly. When referring to static members of those types, use `int.Parse()` instead of `Int32.Parse()`.

**Exception:** When referring to static members of those types, it is custom to use the full CLS name, e.g. `Int32.Parse()` instead of `int.Parse()`. The same applies to members that need to specify the type they return, e.g. `ReadInt32`, `GetUInt16`.
**Exception:** For interop with other languages, it is custom to use the [CLS-compliant name](https://docs.microsoft.com/en-us/dotnet/standard/common-type-system) in type and member signatures, e.g. `HexToInt32Converter`, `GetUInt16`.

0 comments on commit 1eedd41

Please sign in to comment.