Microsoft Dev Blogs

How to use GitHub Copilot Chat in Visual Studio

    thumbnail

    Table of Contents

    1. Exploring code with GitHub Copilot Chat
    2. Converting code
    3. Conclusion

    Exploring code with GitHub Copilot Chat

    In this section, the video demonstrates how to utilize GitHub Copilot Chat to work with arrays and Lists in C#. GitHub Copilot Chat can help users understand the differences in performance and functionality between arrays and Lists, providing code examples and guidance on data manipulation.

    Converting code

    The section showcases how GitHub Copilot Chat can assist in converting code from using arrays to using Lists. The preview feature allows users to see the suggested changes inline before implementing them, providing a visual diff view for comparison. Users are reminded that they are in control of the changes suggested by GitHub Copilot Chat.

    Before:
    int[] numbers = new int[5]; 
    numbers[0] = 10; 
    numbers[1] = 20; 
    numbers[2] = 30; 
    numbers[3] = 40; 
    numbers[4] = 50;
    
    After:
    List<int> numbers = new List<int>(); 
    numbers.Add(10); 
    numbers.Add(20); 
    numbers.Add(30); 
    numbers.Add(40); 
    numbers.Add(50);
    

    Conclusion

    With GitHub Copilot Chat integrated into Visual Studio, developers can benefit from AI-powered coding assistance to write code efficiently and learn new coding practices. By exploring the suggestions and examples provided by GitHub Copilot Chat, users can enhance their coding skills and productivity. Visit our collection of resources or watch the full-length video to further explore GitHub Copilot's capabilities and usage.