Mobile apps, 2D and 3D games, web applications and more can be developed rapidly using C#. C# is a very powerful and flexible .NET programming language.
***NOTE***
In the example given, if the conversion from string to decimal (for the 'annualSalary' variable) causes a runtime error stating that the input string is not in the correct format, you can use the 'Decimal.Parse' method instead of the 'Convert.ToDecimal' method and pass the appropriate 'Console.ReadLine()' method as a parameter to the 'Decimal.Parse' method to resolve this.
Although the code provided in this tutorial is technically not incorrect (because the error is caused by an incompatible configuration setting) and many of you may not experience the issue it is safer to use the code provided below.
annualSalary = Decimal.Parse(Console.Readline(),
NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
Include the following directive,
using System.Globalization;
under using System;
What causes this issue?
On some computers the settings may be such that when inputting a number containing a decimal point, certain culture related settings on the computer may prohibit the use of a full-stop within the inputted number (this is what causes the runtime error). A comma for e.g. may be accepted rather than the full-stop. To illuminate the issue altogether, please use the recommended code provided above.
This is a video clip taken from a free course entitled, "C# for Beginners", which is provided by this channel. The tutorial where this clip is included is entitled, "C# Data Types", and can be viewed at this location, • C# for Beginners - Part 2 - C# Data T... .
This video starts with code creation so for details on the project creation process please view the video at this location, • C# .NET Core Console Application Proj... .
Links
--------
If you’d like to make a donation to help support the channel, please click the link below,
https://www.paypal.com/paypalme/GavinLon
.NET Core Prerequisites - Windows
https://docs.microsoft.com/en-us/dotn...
.NET Core Prerequisites - macOS
https://docs.microsoft.com/en-us/dotn...
Download Visual Studio Community Edition for Windows
https://docs.microsoft.com/en-us/visu...
Download Visual Studio Community Edition for Mac
https://docs.microsoft.com/en-us/visu...
Download Visual Studio Code for Windows and Mac
https://code.visualstudio.com/download
.NET Core SDK - Overview
https://docs.microsoft.com/en-us/dotn...
Download .NET Core SDK
https://dotnet.microsoft.com/learn/do...
Visual Studio Licensing Terms
https://visualstudio.microsoft.com/li...
GitHub
Code
https://github.com/GavinLonDigital/Em...
Documentation
https://github.com/GavinLonDigital/CS...
A special thanks to Mike Koenig (SoundBible) for the following sound effect
Crumble
All music was created by Gavin Lon Digital.
Contact
[email protected]