统一归档20260319
This commit is contained in:
3
CS/lab11/11_4/11_4.slnx
Normal file
3
CS/lab11/11_4/11_4.slnx
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution>
|
||||
<Project Path="11_4/11_4.csproj" />
|
||||
</Solution>
|
||||
11
CS/lab11/11_4/11_4/11_4.csproj
Normal file
11
CS/lab11/11_4/11_4/11_4.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>_11_4</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
34
CS/lab11/11_4/11_4/Program.cs
Normal file
34
CS/lab11/11_4/11_4/Program.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace _11_4
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
const string FILE_NAME = "output.txt";
|
||||
using (StreamWriter sw = new StreamWriter(FILE_NAME))
|
||||
{
|
||||
sw.WriteLine("---------------------");
|
||||
sw.WriteLine("文本文件读取写入示例");
|
||||
sw.WriteLine("---------------------");
|
||||
sw.WriteLine("写入整数、浮点数、bool值、字符、字符串、日期");
|
||||
Console.WriteLine("请输入一个整数");
|
||||
int i = int.Parse(Console.ReadLine());
|
||||
sw.WriteLine(i);
|
||||
Console.WriteLine("写入一个浮点数");
|
||||
double j = double.Parse(Console.ReadLine());
|
||||
sw.WriteLine(j);
|
||||
Console.WriteLine("写入一个bool值");
|
||||
bool k = bool.Parse(Console.ReadLine());
|
||||
sw.WriteLine(k);
|
||||
Console.WriteLine("写入一个字符");
|
||||
char a = char.Parse(Console.ReadLine());
|
||||
sw.WriteLine(k);
|
||||
Console.WriteLine("写入字符串");
|
||||
string b = Console.ReadLine();
|
||||
sw.WriteLine(b);
|
||||
Console.WriteLine("写入当前日期");
|
||||
sw.WriteLine(DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user