mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-04 22:07:39 +00:00
Initial commit
This commit is contained in:
parent
ca7684985d
commit
49bdd4dda1
60 changed files with 1527 additions and 30 deletions
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System.Console" Static="true" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
19
vscode/Chapter03/Ch03Ex04Exceptions/Program.cs
Normal file
19
vscode/Chapter03/Ch03Ex04Exceptions/Program.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Write("Enter a number between 0 and 255: ");
|
||||
string n1 = ReadLine()!;
|
||||
|
||||
Write("Enter another number between 0 and 255: ");
|
||||
string n2 = ReadLine()!;
|
||||
|
||||
try
|
||||
{
|
||||
byte a = byte.Parse(n1);
|
||||
byte b = byte.Parse(n2);
|
||||
|
||||
int answer = a / b;
|
||||
|
||||
WriteLine($"{a} divided by {b} is {answer}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteLine($"{ex.GetType().Name}: {ex.Message}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue