Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Imagine you write a console application and you need to read the configuration from the configuration file, in the strongly typed way.
.NET core comes to help us with it. It's usually demonstrated in ASP.NET Core MVC but it's also possible to use it in the console application. Let's see.
Let's create two configuration classes which will be used to hold the application and the module name.
The application configuration file will look like the following:
At the end, let's use it in the application.
All the magic (binding) is done through "Bind" method.
Don't forget to add the required dependencies. The project.json should contain the following:
Once you run it, the result will be:
Using the strongly typed configuration classes in .NET Core app is easy!
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in