是否可以像在Visual Studio中一样重构变量类型?
No, unfortunately with a vanilla Visual Studio instance there isn't a way to refactor a variable type. it would be almost impossible for automation to do it, at least if you mean change a string to an int for example.
Consider this refactor
string str = "I'm a string";
//Refactor to int would be
int str = "I'm a string";
The above would then cause an error you would have to manually fix. however when using var you can refactor to explcit types.
var str = "I'm a string";
//Refactor to Explicit would be
string str = "I'm a string";
You can however right click a variable and click find all references which will perhaps be helpful in at least identifing all instances where you will have to rename and clicking each will take you straight to them.
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.