Alex Rivera | Logout

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

Asked 2011-05-14T07:48:13.627
41

Not found it in StyleCop Help Manual, on SO and Google so here it is ;)

During StyleCop use I have a warning:

SA1121 - UseBuiltInTypeAlias - Readability Rules

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

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

so String.Empty is wrong (depend on above rules) and string.Empty is good.

Why using built-in aliases is better? Can String. Int32, Int64 (etc.) complicate something in the code on special scenarios?

Edit
Report

2 Answers

1

Because the built in alias is a more natural way to express the concept in that language.

Some cultures say soccer, others say football. Which one is more appropriate depends on the context.

answered 2011-05-14T07:54:02.430
0

Less confusing? It seems very akward to me for a base data type, which traditionally is just a value, to include static functions. I understand using the base data type equivalent if you're just storing a value, but for accessing members of the class, it seems very akward to put a .(dot) after the base type name.

answered 2011-06-01T20:09:50.940

Your Answer