C# 问题合集
Console.ReadLine()奇怪的没有运行
源码简易部分:
public static void Main()
{
int flat;
Console.Write("input your want operation:");
flat = Console.Read();
if (flat == 'a')
{
Console.WriteLine("input you want add chapter number?");
string num = Console.ReadLine();
Console.WriteLine(num);
}
}
问题描述:
string num = Console.ReadLine();
似乎并没有执行,直接跳过。
推测原因:
flat = Console.Read();
的影响下,导致结果。改成flat = Console.ReadLine();
ok!!
无法引用System.Windows.Forms
经了解,.net 6.0框架的WPF应用 是无法直接使用此引用。
需要在右键项目,然后点击 编辑项目文件 中添加<UseWindowsForms>true</UseWindowsForms>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
然而,这个方法,会导致大量winForm与WPF的冲突。所以PASS
改为:
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix