Các chương trình C# trong loạt bài này được chạy trên Visual Studio 2010, do đó chương này mình xin hướng dẫn cho các bạn cách tạo một Project trong Visual Studio 2010 và cách để Run một chương trình C# trong Visual Studio 2010 như thế nào.

Bạn đang xem: Cách mở 1 project trong visual studio

Cách tạo Project trong Visual Studio 2010

Sau khi bạn đã cài đặt xong Visual Studio 2010, để tạo một Project mới, bạn click chuột vào biểu tượng File, sau đó chọn New --> Project hoặc nhấn tổ hợp phím Ctrl + Shift + N để tạo một project mới.

Bởi vì mình đã tạo một C# Project trước đó rồi nên một hộp thoại sau sẽ hiển thị:

*
Nếu bạn lần đầu tiên tạo, bạn click chuột vào Installed Templates --> Other Languages --> Visual Studio thì cũng sẽ hiển thị hộp thoại tương tự.

Trong hình trên:

Với các chương trình C# nhỏ và cơ bản như trong loạt bài này hoặc khi bạn muốn nhìn thấy kết quả trên màn hình Console, bạn nên chọn Console Application.Trong phần Name chính là nơi bạn đặt tên cho Project của mình, như dưới đây.

*
Sau đó bạn nhấn Ok để tạo một Project mới với tên bạn đã đặt.

Cách run C# project trong Visual Studio 2010

Để viết code, bạn click chuột vào Program.cs:

*
Trong hình trên:

Lệnh System.Console.Write
Line("Viet
Jack chuc cac ban hoc tot !!!");
là để in một dòng chữ trên màn hình Console.Nếu bạn không sử dụng lệnh Console.Read
Key();
thì chương trình sẽ chạy và kết thúc luôn (nhanh quá đến nỗi bạn không kịp nhìn kết quả). Lệnh này cho phép chúng ta nhìn kết quả một cách rõ ràng hơn. Bạn tự so sánh hai trường hợp dùng và không dùng nhé.

Để chạy chương trình C# trong Visual Studio 2010, bạn nhấn phím F5. Chương trình trên của mình sẽ cho kết quả sau:

*
Cách tạo Class mới trong C# Project trong Visual Studio

Để tạo một Class mới, bạn click chuột phải vào tên project (như ở trên thì tên project của mình là Viet
Jack
Csharp
), sau đó chọn Add --> New Item hoặc nhấn tổ hợp phím Ctrl + Shift + A, hộp thoại sau sẽ hiện ra:

*
Trong khung ở giữa, bạn chọn Class, và ở phần Name là nơi bạn đặt tên cho class của mình. Sau khi bạn đặt tên xong, nhấn Add để tạo class mới.

Trong bài viết này

Applies to:

*
Visual Studio
*
Visual Studio for Mac
*
Visual Studio Code

In this article, we"ll show you how to quickly create a new project in Visual Studio from a template.


Open the "Create a new project" dialog

There are multiple ways to create a new project in Visual Studio. When you first open Visual Studio, the start window appears, and from there, you can select Create a new project.

*

If the Visual Studio development environment is already open, you can create a new project by choosing File > New > Project on the menu bar. You can also select the New Project button on the toolbar, or press Ctrl+Shift+N.

*


Open the "Create a new project" dialog

There are multiple ways to create a new project in Visual Studio. When you first open Visual Studio, the start window appears, and from there, you can select Create a new project.

*

If the Visual Studio development environment is already open, you can create a new project by choosing File > New > Project on the menu bar. You can also select the New Project button on the toolbar, or press Ctrl+Shift+N.

*


Select a template type

On the Create a new project dialog, a list of your recently selected templates appears on the left. The templates are sorted by most recently used.

If you"re not selecting from the recently used templates, you can filter all available project templates by Language (for example, C# or C++), Platform (for example, Windows or Azure), and Project type (for example, Desktop or Web). You can also enter search text into the search box to further filter the templates, for example, asp.net.


*

The tags that appear under each template correspond to the three dropdown filters (language, platform, and project type).


Tip

If you don"t see the template you"re looking for, you might be missing a workload for Visual Studio. To install additional workloads, for example, Azure Development or Mobile Development with .NET, select the Install more tools and features link to open Visual Studio Installer. From there, select the workloads you want to install, and then select Modify. After that, additional project templates will be available to choose from.

*


*

The tags that appear under each template correspond to the three dropdown filters (language, platform, and project type).


Tip

If you don"t see the template you"re looking for, you might be missing a workload for Visual Studio. To install additional workloads, for example, Azure Development or Mobile Development with .NET, select the Install more tools and features link to open Visual Studio Installer. From there, select the workloads you want to install, and then select Modify. After that, additional project templates will be available to choose from.

*


Configure your new project

The Configure your new project dialog has options to name your project (and solution), select a disk location, and select a Framework version (if applicable to the template you chose).

*


Note

If you create a new project when you already have a project or solution open in Visual Studio, an extra configuration option is available. You can choose to create a new solution or add the new project to the solution that"s already open.

*


Configure your new project

The Configure your new project dialog has options to name your project (and solution), select a disk location, and more.

*

The Additional information dialog includes options to select a Framework version, an authentication type, and more.

*

Select Create to create the new project.


Add another project to a solution

If you want to add another project to a solution, right-click the solution node in Solution Explorer and then select Add > New Project.

Xem thêm: Tải bản đồ thành phố lạng sơn ❤️_❤️ khổ lớn phóng to năm 2023


Tip

For an example of a project and solution created from scratch, complete with step-by-step instructions and sample code, see Introduction to projects and solutions.