Navigation:  StyleCop 4.3 > StyleCop 4.3 Rules > Readability Rules >

SA1121: UseBuiltInTypeAlias

Previous pageReturn to chapter overviewNext page
StyleCop 4.3

Send comments on this topic.

SA1121: UseBuiltInTypeAlias

Glossary Item Box

TypeName
UseBuiltInTypeAlias

CheckId

SA1121

Category

Readability Rules

 

Cause

The code uses one of the basic C# types, but does not use the built-in alias for the type.

Rule Description

A violation of this rule occurs when one of the following types are used anywhere in the code: Array, Boolean, Byte, Char, Decimal, Double, Int16, Int32, Int64, Object, SByte, Single, String, UInt16, UInt32, UInt64.

A violation also occurs when any of these types are represented in the code using the full namespace for the type: System.Array, System.Boolean, System.Byte, System.Char, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.Object, System.SByte, System.Single, System.String, System.UInt16, System.UInt32, System.UInt64.

Rather than using the type name or the fully-qualified type name, the built-in aliases for these types should always be used: array, bool, byte, char, decimal, double, short, int, long, object, sbyte, single, string, ushort, uint, ulong.

The following table lists each of these types in all three formats:

Type Alias

Type

Fully Qualified Type

array            

Array

System.Array

bool

Boolean

System.Boolean

byte

Byte

System.Byte

char

Char

System.Char

decimal

Decimal

System.Decimal

double

Double

System.Double

short

Int16

System.Int16

int

Int32

System.Int32

long

Int64

System.Int64

object

Object

System.Object

sbyte

SByte

System.SByte

single

Single

System.Single

string

String

System.String

ushort

UInt16

System.UInt16

uint

UInt32

System.UInt32

ulong

UInt64

System.UInt64

 

How to Fix Violations

To fix a violation of this rule, replace the type with the built-in alias for the type.

 


© Microsoft Corporation. All Rights Reserved.