How can I reverse code around an equal sign in Visual Studio?

后端 未结 4 842
一个人的身影
一个人的身影 2020-12-12 20:29

After writing code to populate textboxes from an object, such as:

txtFirstName.Text = customer.FirstName;
txtLastName.Text = customer.LastName;
txtAddress.Te         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-12 20:56

    Before VS2012:

    • Copy and paste the original block of code
    • Select it again in the place you want to switch
    • Press Ctrl-H to get the "Replace" box up
    • Under "Find what" put: {[a-zA-Z\.]*} = {[a-zA-Z\.]*};
    • Under "Replace with" put: \2 = \1;
    • Look in: "Selection"
    • Use: "Regular expressions"
    • Hit Replace All

    With VS2012 (and presumably later) which uses .NET regular expressions:

    • Copy and paste the original block of code
    • Select it again in the place you want to switch
    • Press Ctrl-H to get the "Replace" box up
    • Under "Find what" put: ([a-zA-Z\.]*) = ([a-zA-Z\.]*);
    • Under "Replace with" put: ${2} = ${1};
    • Make sure that the .* (regular expressions) icon is selected (the third one along under the replacement textbox)
    • Hit Replace All

提交回复
热议问题