Circle – Line Intersection工作不正常?

我在http://mathworld.wolfram.com/Circle-LineIntersection.html之后写了这个圆线交叉检测,但看起来好像它或我遗漏了一些东西。 public static bool Intersect (Vector2f CirclePos, float CircleRad, Vector2f Point1, Vector2f Point2) { Vector2f p1 = Vector2f.MemCpy(Point1); Vector2f p2 = Vector2f.MemCpy(Point2); // Normalize points p1.X -= CirclePos.X; p1.Y -= CirclePos.Y; p2.X -= CirclePos.X; p2.Y -= CirclePos.Y; float dx = p2.X – p1.X; float dy = p2.Y – p1.Y; float dr = (float)Math.Sqrt((double)(dx * dx) […]

如何确保NetworkStream在不关闭Stream或TcpClient的情况下立即发送数据?

我有一个非常简单的代码片段,它试图通过TcpClient及其相关的NetworkStream发送数据。 var client = new TcpClient(“xxx.xxx.xxx.xxx”, 1234); NetworkStream stream = client.GetStream(); byte[] buffer = Encoding.ASCII.GetBytes(str); stream.Write(buffer, 0, buffer.Length); 我发现通常在stream.Write()之后不会立即发送数据。 如果我添加stream.Close() client.Close()或stream.Close()那么将发送数据。 但是,在我的情况下,我正在尝试等待服务器发送一些ACK消息,所以我想重用原始的NetworkStream而不关闭TcpClient或NetworkStream 。 如何才能做到这一点?

asp.net中服务器端的会话超时c#

我有会话超时的问题,即使我在web.config中添加了如下代码,但它不起作用,它在10分钟内到期。 服务器的会话超时为20分钟。 请帮我解决会话超时问题?

硬件序列号

如何获取c#.net中所有类型硬盘的序列号

模拟对象没有Intellisense中显示的所有属性 – 在一个项目中但在另一个项目中有它们

我在嘲笑VSTO对象,在一个项目中(我没写),它有这样的代码: var listOfSheets = new List(); var mockSheets = Substitute.For(); mockSheets.Count.Returns(listOfSheets.Count); mockSheets的Intellisense ToolTip显示了6个属性: 具有断点的线在此项目中起作用。 但是我在不同的项目中使用相同的代码(相同的引用,名称空间等),但是mockSheets的Intellisense ToolTip只显示1个属性: 我知道这是我试图解决的根本原因,但实际问题是: 无法对空引用执行运行时绑定 编辑: Sheet对象被模拟: public static Worksheet Sheet { get { var mockSheet = Substitute.For(); mockSheet.Name = MockSheetName; mockSheet.Visible = XlSheetVisibility.xlSheetVisible; return mockSheet; } } public static Workbook Workbook() { return Workbook(1); }

注入require对象取决于构造函数注入中的条件

我有一个界面 public interface ITrnsitReport { List GetTransitReportData (); } 它只有一个实现 public class TransitReport : ITrnsitReport { private IValidateInput _inputValidation = null; private readonly ITransitRepository _transitRepo = null; public TransitReport (IValidateInput inputValidation, ITransitRepository transitRepo) { _inputValidation = inputValidation; _transitRepo = transitRepo; } public List GetTransitReportData (string input1, string input2) { List ppdcReportList = null; bool isValid […]

c# – 如何在不让应用程序关闭的情况下关闭主窗体?

我想做的事: – >打开MDI表单 – >关闭项目主窗体 – >不关闭应用程序 我做了什么: frmMain fm = new frmMain(); fm.Show(); this.Close() 任何帮助,将不胜感激! 🙂

将UWP App连接到远程SQL Server 2008提供程序:TCP提供程序,错误:0

System.Data.SqlClient.SqlException:’已成功与服务器建立连接,但在登录过程中发生错误。 (提供者:TCP提供者,错误:0 – 操作成功完成)’ 我正在尝试使用UWP APP连接到SQL Server 2008 R2数据库。 远程访问已启用 防火墙规则已到位 目标版本是Windows 10 Fall Creators Update(10.0; Bulid 16299 最小版本是Windows 10 Fall Creators Update(10.0; Bulid 16299 Package.appxmanifest设置为 internetClient internetClientServer privateNetworkClientServer enterpriseAuthentication 码: using System.Data.SqlClient; const string ConnectionString = “SERVER = XXXServer; DATABASE = XXXDatabase; USER ID = XXXUser; PASSWORD = XXXPass”; using (SqlConnection sqlConn = new […]

为什么在BindingList更改时会清除ComboBox.SelectedValue DataBinding上下文?

我在业务层中有一些逻辑根据输入限制ComboBox选项,所以我需要更改底层BindingList中的值。 但是当列表发生变化时,双向绑定将成为从UI到Entity的单向绑定。 _mComboBox.DataBindings.Add(“SelectedValue”, _mEntity, “WifeCount”); 分配按钮单击处理程序中存在问题的完整代码: using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace EnumDataBinding { public partial class Form1 : Form { ComboBox _mComboBox = new ComboBox(); Button _mCheckButton = new Button(); Button _mAssignButton = new Button(); BindingList _mBindingList = new BindingList(); List […]

对文件C#执行OS命令

我试图通过C#执行操作系统命令。 我从这个网页上获得了以下代码: //Execute command on file ProcessStartInfo procStart = new ProcessStartInfo(@”C:\Users\Me\Desktop\Test\System_Instructions.txt”, “mkdir testDir”); //Redirects output procStart.RedirectStandardOutput = true; procStart.UseShellExecute = false; //No black window procStart.CreateNoWindow = true; //Creates a process System.Diagnostics.Process proc = new System.Diagnostics.Process(); //Set start info proc.StartInfo = procStart; //Start proc.Start(); 但是当我尝试运行代码时,我收到以下错误: {“The specified executable is not a valid application for this OS […]