开发者

In VS 2008, how to do re-assign all classes that use a global variable to another class with the new variable?

开发者 https://www.devze.com 2023-01-07 06:24 出处:网络
Is there a shortcut that allows me to repoint all classes that use the old object and repoint them all to the new class that has the new object?

Is there a shortcut that allows me to repoint all classes that use the old object and repoint them all to the new class that has the new object?

and i don't mean ju开发者_Python百科st doing a Ctrl+F then replace.


If they're all using a global variable, presumably they're referring to it as

TypeName.variableName

aren't they? Can't you just do a search and replace?

It's possible that the refactoring tools will help you with this too, but I suspect in this case a search and replace is just as easy.

EDIT: I've just tried myself, and it's certainly easy with Resharper: select the variable, right-click, Refactor, Move. Not sure about the native capabilities of VS2008 though.

Another option: change the design not to use a global variable in the first place. Dependency injection rocks :)

0

精彩评论

暂无评论...
验证码 换一张
取 消