Skip to content

Commit c351da5

Browse files
committed
Merged main into live
2 parents 25ab862 + 7530643 commit c351da5

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

docs/get-started/csharp/run-program.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
title: "How to run a program (C#)"
33
description: Start programming with C# in Visual Studio and run programs from a project or code file, work with assemblies, references, NuGet packages, and .NET.
44
ms.custom: vs-acquisition
5-
ms.date: 2/13/2024
5+
ms.date: 12/10/2024
66
ms.subservice: general-ide
7-
87
ms.topic: tutorial
98
ms.devlang: csharp
109
author: ghogen
@@ -13,9 +12,9 @@ manager: mijacobs
1312
dev_langs:
1413
- csharp
1514
---
16-
# Run a C# program in Visual Studio
15+
# Run a C# program or app in Visual Studio
1716

18-
How to run a program depends on what you start from, the type of program, and whether you want to run under the debugger. In the simplest case, to build and run an open project in Visual Studio:
17+
How to run a program or start an app depends on what you start from, the type of program or app, and whether you want to run under the debugger. In the simplest case, to build and run an open project in Visual Studio:
1918

2019
- Press **F5**, choose **Debug** > **Start with debugging** from the Visual Studio menu, or select the green **Start** arrow and project name on the Visual Studio toolbar.
2120
- Or, to run without debugging, press **Ctrl**+**F5** or choose **Debug** > **Start without debugging** from the Visual Studio menu.
@@ -29,9 +28,11 @@ How to run a program depends on what you start from, the type of program, and wh
2928

3029
## Start from a project
3130

32-
You can run a C# project (*.csproj* file) if it's a runnable program. If the project contains a C# file with a `Main` method, and its output is an executable or *.exe* file, it will probably run if it builds successfully. Newer versions of C# don't require a `Main` method; instead, program executions starts with top-level statements. See [Programs without Main methods](/dotnet/csharp/fundamentals/program-structure/top-level-statements). If a project has no `Main` method and no top-level statements, then it might be a class library. If so, it's not runnable on its own, but it can be referenced by other projects.
31+
You can run a C# project (`.csproj` file) if it's a runnable program. If the project contains a C# file with a `Main` method, and its output is an executable or `.exe` file, it will probably run if it builds successfully. If your project output is an executable file, and doesn't have a `Main` method, program executions starts with top-level statements. See [Programs without Main methods](/dotnet/csharp/fundamentals/program-structure/top-level-statements). Some project types, such as class libraries, are not runnable. Class libraries are not runnable on their own, but they can be referenced by other projects.
32+
33+
If you're not sure if the project you have is an executable file, select the project node in Solution Explorer, and open the project properties. Either right-click on the node to bring up the context menu, and choose **Properties**, or press **Alt**+**Enter**. In the **Application** section, look for the **Output type**. If it's **Console Application**, then it's a runnable program.
3334

34-
1. If your program code is already in a Visual Studio project, open the project. To do so, you can double-click or tap on the *.csproj* file in Windows File Explorer, or choose **Open a project** in Visual Studio, browse to find the *.csproj* file, and select the file.
35+
1. Open the project. To do so, you can double-click or tap on the `.csproj` file in Windows File Explorer, or choose **Open a project** in Visual Studio, browse to find the `.csproj` file, and select the file.
3536

3637
1. After the project loads in Visual Studio, if your Visual Studio solution has more than one project, make sure to set the project with the `Main` method as the startup project. To set the startup project, right-click on the project name or node in **Solution Explorer** and choose **Set as Startup Project** from the context menu.
3738

@@ -50,15 +51,17 @@ You can run a C# project (*.csproj* file) if it's a runnable program. If the pro
5051

5152
## Start from code
5253

53-
If you start from a code listing, code file, or small number of files, first make sure the code is a runnable program from a trusted source. Any app with a `Main` method is probably a runnable program, but with the current version of C#, programs without `Main` methods with top-level statements can also run. You can use the Console Application template to create a project to work with the app in Visual Studio.
54+
If have a runnable C# code sample in mind such as [this one](https://www.sanfoundry.com/csharp-program-check-given-number-even-odd/), or a runnable C# code file or files on disk, follow these steps.
55+
56+
First make sure the code is a runnable program from a trusted source. Any app with a `Main` method is probably a runnable program, but with the current version of C#, programs without `Main` methods with top-level statements can also run. You can use the Console Application template to create a project in Visual Studio, and then copy the code intoit.
5457

55-
### Code listing for a single file
58+
### A single code file
5659

5760
1. Start Visual Studio, choose **Create a new project**, and choose the C# **Console App** project.
58-
1. Replace all the code in the project *.cs* file with the contents of your code listing or file. If the code you want to use is on the web, or in a single file, it might be easiest to select the code, copy it to the clipboard, and paste it into a code file in the Visual Studio project.
59-
1. Rename the project *.cs* file to match your code file name.
61+
1. Replace all the code in the project `.cs` file with the contents of your code or file. If the code you want to use is on the web, or in a single file, it might be easiest to select the code, copy it to the clipboard, and paste it into a code file in the Visual Studio project.
62+
1. Rename the project `.cs` file to match your code file name.
6063

61-
### Several code listings or files on disk
64+
### Several code files on disk
6265

6366
1. Start Visual Studio, and create a new project of the appropriate type. Use the C# **Console App** if you're not sure.
6467
1. In the new project, replace all the code in the project code file with the contents of your first code listing or file.
@@ -69,7 +72,7 @@ If you start from a code listing, code file, or small number of files, first mak
6972

7073
### Several files in a folder
7174

72-
If you have a folder with many files, first check for a project or solution file. Programs that Visual Studio creates have project and solution files. In Windows File Explorer, look for files with the *.csproj* or *.sln* extension. Double-click the *.csproj* file to open it in Visual Studio. See [Start from a Visual Studio solution or project](#start-from-a-project).
75+
If you have a folder with many files, first check for a project or solution file. Programs that Visual Studio creates have project and solution files. In Windows File Explorer, look for files with the `.csproj` or `.sln` extension. Double-click the `.csproj` file to open it in Visual Studio. See [Start from a Visual Studio solution or project](#start-from-a-project).
7376

7477
If the code is from another development environment, there's no project file. Open the folder by choosing **Open** > **Folder** in Visual Studio. See [Develop code without projects or solutions](../../ide/develop-code-in-visual-studio-without-projects-or-solutions.md).
7578

docs/ide/code-styles-and-code-cleanup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Code style options and code cleanup
3-
description: Learn how to configure Visual Studio to apply code style preferences using the Code Cleanup (Visual Studio 2019) and Format Document (Visual Studio 2017) commands.
3+
description: Learn how to configure Visual Studio to apply code style preferences using the Code Cleanup command.
44
ms.date: 11/11/2024
55
ms.topic: conceptual
66
author: mikejo5000

docs/ide/how-to-change-fonts-and-colors-in-visual-studio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ You can change the font and text size for all the IDE frame and tool windows, or
137137

138138
### Preserve font settings across theme changes
139139

140-
With Visual Studio 2002 version 17.12, you can now preserve your font and font size preferences across theme changes. This functionality is enabled by default. When you switch themes in Visual Studio, your custom font face and size settings remain unchanged, while the font color updates with the new theme.
140+
With Visual Studio 2022 version 17.12, you can now preserve your font and font size preferences across theme changes. This functionality is enabled by default. When you switch themes in Visual Studio, your custom font face and size settings remain unchanged, while the font color updates with the new theme.
141141

142142
If you prefer to have font selections change with the theme, select **Tools** > **Manage Preview Features** and uncheck **Separate font settings from color themes selection (requires restart)**.
143143

0 commit comments

Comments
 (0)