Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefining C# keywords?

Tags:

c#

.net

Is it possible to redefine a C# keyword like int to use Int64 instead of Int32?

If not, how can one do this? I want to have the flexibility to redefine the int I use, so later I could change it to int64 if I wanted, instead of going around to replace all the int values manually.

like image 786
Joan Venge Avatar asked Nov 29 '22 12:11

Joan Venge


2 Answers

No it's not possible and you really should not be doing this. Redefining keywords to custom values will only serve to make your code less readable and maintainable. People getting introduced to your code base would have to forget everything they know about C# defaults and learn your defaults. This is not a good way to make a maintainable code base.

What you should consider though is creating a new type name and using a "using alias" to redirect that type within your code base.

using FexibleInt = System.Int32;
like image 195
JaredPar Avatar answered Dec 15 '22 06:12

JaredPar


Add

using MyIntType = System.Int64;

after the namespace declaration.

like image 40
mmx Avatar answered Dec 15 '22 06:12

mmx