Is it possible to refactor a variable type just like its name in 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With