Multiple string constants into const string
When I write code I use strings literals I write them directly in the code and then later on translate them in to a const string.
As I recall, earlier versions could help me with this and even suggest that multiple instances of the same string constant will reference to the introduced const variable.
Has this been removed ? If not, could some one show me how?
I use v5.1
Please sign in to leave a comment.
Hello Soren,
You can select a const string and then choose ReSharper | Refactor | Introduce
Field or Introduce Variable, ReSharper will then suggest to replace all occurrences
of that string and replace them with constant field or local variable. Let
me know if this helps. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Hi that looks perfect except for one detail.... I would like the name suggestion to be ALL_UPPER. For instance
const string MY_VALUE = "MyValue";
Is that possible? C# Naming style settings does not seem to affect the suggestion
Thanks for your help
Hello Soren,
You're right, naming style is not taken into account in this situation. I've
logged a problem at http://youtrack.jetbrains.net/issue/RSRP-231815 and you're
welcome to monitor its status. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"