Getting started
C# is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in .NET.
This guide shows how to create and run a .NET console application by using Visual Studio Code and the .NET CLI (command-line interface). Project tasks, such as creating, compiling, and running a project are done by using the .NET CLI. You can follow this tutorial with a different code editor and run commands in a terminal if you prefer.
Prerequisities
-
Visual Studio Code with the C# extension installed. For information about how to install extensions on Visual Studio Code, see VS Code Extension Marketplace.
Create a console application
Create a .NET console app project named HelloStruSoft.
-
Start Visual Studio Code.
-
Select File > Open Folder from the main menu.
-
In the Open Folder dialog, create a HelloStruSoft folder and select it. Then click Select Folder
-
The folder name becomes the project name and the namespace name by default. You'll add code later in the tutorial that assumes the project namespace is
HelloStruSoft. -
Open the Terminal in Visual Studio Code by selecting View > Terminal from the main menu.
The Terminal opens with the command prompt in the
HelloStruSoftfolder. -
In the Terminal, enter the following command:
dotnet new consoledotnet add package FemDesign.CoreThe project template creates a simple application that displays "Hello World" in the console window by calling the
Console.WriteLine(String)method in Program.cs. -
Replace the contents of Program.cs with the following code:
using FemDesign;
namespace HelloStruSoft
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to FEM-Design API!\n");
var point = new FemDesign.Geometry.Point3d(0, 0, 0);
Console.WriteLine($"You have just created a Point3d in {point.X}, {point.Y}, {point.Z}.");
}
}
}The code defines a class,
Program, with a single method,Main, that takes a String array as an argument.Mainis the application entry point, the method that's called automatically by the runtime when it launches the application. Any command-line arguments supplied when the application is launched are available in the args array.
Run the application
Run the following command in the Terminal:
dotnet run
The program displays
Welcome to FEM-Design API!
You have just created a Point3d in 0, 0, 0.
Congratulations, you have successfully created your first FEM-Design Application! 🎉