I have been writing String.IsNullOrEmpty for years, and in Visual Studio 2015, the IDE suggests to refactor it into string.IsNullEmpty, Why? what would you do?
I well understand what behind String and string, however, I just wonder why VS 2015 could give me a hint I don't need.
It's due to a "Code Style" option, under:
Tools / Options / Text Editor / C# / Code Style
Uncheck the following option, and it should stop warning you.
If you find the styles useful, in that they force a certain uniformity on your code that you like to be warned about, then leave it checked. Personally, I'd just uncheck it.
The IDE suggests to refactor it into string.IsNullEmpty, Why?
Actually there is no difference between String
and string
since both are same and string
is just an alias. If VS still complaining about re-factoring it then probably because of some FxCop
code analysis rules. You may want to verify the same.
In one of my work experience, they had a FxCop
custom rule setup to use the actual Type name instead of alias like use String
instead of string
(OR) Int32
instead of int
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.