且运算和IF用例

This commit is contained in:
岛风 2024-12-14 18:08:48 +08:00
parent de72242125
commit 0c90bca6c0
5 changed files with 145 additions and 0 deletions

View File

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld\He
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "intVariable", "intVariable\intVariable.csproj", "{E4F0A953-68EB-4231-AE4C-040E1A13747A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "intVariable", "intVariable\intVariable.csproj", "{E4F0A953-68EB-4231-AE4C-040E1A13747A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "doif", "doif\doif.csproj", "{D927AAFB-7F50-43BE-B3E1-62364060B642}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{E4F0A953-68EB-4231-AE4C-040E1A13747A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4F0A953-68EB-4231-AE4C-040E1A13747A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4F0A953-68EB-4231-AE4C-040E1A13747A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4F0A953-68EB-4231-AE4C-040E1A13747A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4F0A953-68EB-4231-AE4C-040E1A13747A}.Release|Any CPU.Build.0 = Release|Any CPU {E4F0A953-68EB-4231-AE4C-040E1A13747A}.Release|Any CPU.Build.0 = Release|Any CPU
{D927AAFB-7F50-43BE-B3E1-62364060B642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D927AAFB-7F50-43BE-B3E1-62364060B642}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D927AAFB-7F50-43BE-B3E1-62364060B642}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D927AAFB-7F50-43BE-B3E1-62364060B642}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

6
doif/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

47
doif/Program.cs Normal file
View File

@ -0,0 +1,47 @@
using System;
class LogicalAndDemo
{
static void Main()
{
// 提示用户输入年龄
Console.Write("请输入您的年龄: ");
string ageInput = Console.ReadLine();
// 尝试将输入转换为整数类型
int age;
bool isValidAge = int.TryParse(ageInput, out age);
// 提示用户是否同意条款
Console.Write("您是否同意条款? (yes/no): ");
string agreement = Console.ReadLine();
// 判断用户是否同意条款(忽略大小写)
bool isAgreed = agreement.ToLower() == "yes";
/*
* 使 `&&`
* 1.
* 2.
* 3. 18100
*
* true
*
*/
if (isValidAge && isAgreed && age >= 18 && age <= 100)
{
Console.WriteLine("欢迎加入!");
}
else
{
Console.WriteLine("抱歉,您无法加入。");
}
/*
*
* - `&&`
* - false
* - true
*/
}
}

View File

@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("doif")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("doif")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d927aafb-7f50-43be-b3e1-62364060b642")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

53
doif/doif.csproj Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D927AAFB-7F50-43BE-B3E1-62364060B642}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>doif</RootNamespace>
<AssemblyName>doif</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>