Monday, August 1, 2011

Formatting your code on Visual Studio

On Visual Studio, if you have misaligned lines of code, to align them altogether, highlight the misaligned code code, then press Ctrl+E+F

        class MyClass
        {
    void A()
    {
            int i = 1;
        if (i == 1)
            {
                Console.WriteLine(""); }
  }
    }

Result:
    class MyClass
    {
        void A()
        {
            int i = 1;
            if (i == 1)
            {
                Console.WriteLine("");
            }
        }
    }


That functionality can also be reached under Edit > Advanced > Format Selection.

To format the whole code, press Ctrl+E+D

No comments:

Post a Comment