Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
namespace Lesson8
|
||||
{
|
||||
class program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region 输入数字练习
|
||||
try
|
||||
{
|
||||
Console.Write("请输入一个数字:");
|
||||
int num = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine($"你输入的数字是: {num}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("请你输入一个数字");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine("程序执行完毕!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 录入成绩练习
|
||||
try
|
||||
{
|
||||
int yuWen, shuXue, yingYu;
|
||||
Console.Write("请你输入你的名字:");
|
||||
string name = Console.ReadLine();
|
||||
Console.Write("请你输入你的语文成绩:");
|
||||
yuWen = int.Parse(Console.ReadLine());
|
||||
Console.Write("请你输入你的数学成绩:");
|
||||
shuXue = int.Parse(Console.ReadLine());
|
||||
Console.Write("请你输入你的英语成绩:");
|
||||
yingYu = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine($"你的语文成绩是:{yuWen},你的数学成绩是{shuXue},你的英语成绩是:{yingYu}.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("成绩录入时发生了错误");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine("成绩录入完毕!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user