小编Hen*_*man的帖子

分组和排序算法有帮助

让我们说,当使用时,我有一百万个人物

person1.Matches(person2);

返回true或false.

我想把它们分组.这些群组由任何一个人与群组中的任何其他人匹配.因此,来自一个组的任何人都不会与来自另一组的任何人匹配.一组中的任何人将匹配同一组中的至少一个人.例如,如果一个人是无性的,那么它将形成一个人的群体.一对忠诚的已婚夫妇将组成两人一组.丈夫和他的妻子以及他的情妇和情妇丈夫将形成一组4人.

您知道,此算法将用于分析几何.

algorithm recursion

0
推荐指数
1
解决办法
266
查看次数

ToolStripSeparator的问题

我有一个工具条.对于这个工具条,我正在添加ToolStripSplitButton,为此ToolStripSplitButton,我正在添加工具条项目,包括ToolStripSeparator.在工具条项目的click事件中,我ToolStripSplitButton使用下面的代码从下拉列表中检索项目.

 ToolStripDropDown tditems = ((System.Windows.Forms.ToolStripDropDownItem)(items[0])).DropDown;
foreach (ToolStripMenuItem item in tditems.Items)
{
//something here
}
Run Code Online (Sandbox Code Playgroud)

由于下拉项目同时具有工具条项目并且ToolStripSeparator在运行时,它会给出以下错误.

附加信息:无法将类型为"System.Windows.Forms.ToolStripSeparator"的对象强制转换为"System.Windows.Forms.ToolStripMenuItem".

有谁能够帮我?

谢谢

.net toolstrip winforms

0
推荐指数
1
解决办法
2839
查看次数

空参考例外

"你调用的对象是空的."

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace XNAdev
{
    class Sprite
    {
        //The size of the Sprite
        public Rectangle Size;

        //Used to size the Sprite up or down from the original image
        public float Scale = 1.0f;

        //The current position of the Sprite
        public Vector2 Position = new Vector2(115, 0);
        //The texture object used when drawing the sprite
        private Texture2D mSpriteTexture;

        //Load the texture for the sprite using the Content Pipeline …
Run Code Online (Sandbox Code Playgroud)

c# xna 2d sprite nullreferenceexception

0
推荐指数
1
解决办法
1567
查看次数

文本框在.net中被禁用时的背景和前景色是什么?

文本框在.net中被禁用时的背景和前景色是什么?

c# winforms

0
推荐指数
1
解决办法
270
查看次数

C# - Thread.Sleep的替代方案?

我在Visual Studio 2008中用C#做这一切.

我想减慢算法的工作速度,以便用户可以观察它的工作.在GUI上可以看到周期性变化,所以我在每个实例后添加了"thread.sleep".

问题是"thread.sleep",当设置为至少一秒时,在"thread.sleep"的几个实例(在几个循环之后)之后简单地冻结整个GUI并保持这种方式直到程序完成.不是马上,但它总是发生.多久取决于睡眠的长短.

我有证据表明整个程序都没有冻结,它正在工作,即使睡眠正在暂停正确的长度.但是GUI会在某个时刻冻结,直到算法结束,此时它会显示正确的最终状态.

如何解决这个问题?在某些时候暂停算法的替代方案?

c# visual-studio-2008 slowdown

0
推荐指数
1
解决办法
2276
查看次数

如何在matlab中获取矩阵的最小值和最大值?

我有一些像这样的数字vee(:,:).它有30行和2列.

当我尝试获得第二列的最小值和最大值时,我使用;

ymax = max(vee(:,2));
ymin = min(vee(:,2)); 
Run Code Online (Sandbox Code Playgroud)

有用

当我想要第一列的最小值和最大值时,我会使用

xmax = max(vee(1,:));
xmin = min(vee(1,:));
Run Code Online (Sandbox Code Playgroud)

我不知道矩阵尺寸我可能是错的.为什么xmin和xmax不起作用?它只给出了第一行的值.这有什么不对?

matlab

0
推荐指数
1
解决办法
2003
查看次数

Stringbuilder正在转义HTML符号

我有一个观点,即根据模型发送的内容构建一个下拉列表.

@{
StringBuilder sb = new StringBuilder("<select id=\"field"+Model.Id+"\">");
sb.Append("<option>Choose...</option>");
foreach(var s in Model.Choices)
{
    sb.Append("<option>" + s + "</option>");
}
sb.Append("</select>");
var str = sb.ToString();
}

$("#label" + "@Model.Id").html("@str");
Run Code Online (Sandbox Code Playgroud)

但是在浏览器中,它实际上输出的是整个字符串,而不是创建下拉列表 "<select id="field3"><option>Choose...</option><option>Movie</option><option>TV Show</option><option>Shorts</option></select>"

为什么这样做?如何让它显示实际的下拉列表?

html c# asp.net-mvc-3

0
推荐指数
1
解决办法
2280
查看次数

C#,如何计算操作字符串

我有一个这样的字符串

str = "4975 + 10 * (LOG(250.6)) - 321.2"
Run Code Online (Sandbox Code Playgroud)

我想计算这个操作的结果.有没有办法做到这一点?

// my operation just includes some of operators (,), +, -, *, / , ., 0-9, LOG
// '.' is used for double number
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
121
查看次数

C#中的后代没有给出正确的价值

我是非常新的XML使用C#我有一个XML我需要通过父亲中的特定子项我需要获取id和调用变量变量我这样做但每次都没有通过循环

我需要通过xml的所有父项,直到我得到我想要的树吗?

xml

<message xmlns="jabber:client" to="1072@finesse1.dcloud.cisco.com" id="/finesse/api/User/1072/Dialogs__1072@finesse1.dcloud.cisco.com__104Y2" from="pubsub.finesse1.dcloud.cisco.com">
<event xmlns="http://jabber.org/protocol/pubsub#event">
 <items node="/finesse/api/User/1072/Dialogs">
  <item id="460c2d27-c914-4c24-a95f-edf9f8df45c21535">
    <notification xmlns="http://jabber.org/protocol/pubsub">
      <Update>
        <data>
          <dialogs>
            <Dialog>
              <associatedDialogUri></associatedDialogUri>
              <fromAddress>1071</fromAddress>
              <id>18639330</id>
              <mediaProperties>
                <DNIS>1072</DNIS>
                <callType>AGENT_INSIDE</callType>
                <dialedNumber>1072</dialedNumber>
                <outboundClassification></outboundClassification>
                <callvariables>
                  <CallVariable>
                    <name>callVariable1</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable2</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable3</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable4</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable5</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable6</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable7</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable8</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable9</name>
                    <value></value>
                  </CallVariable>
                  <CallVariable>
                    <name>callVariable10</name>
                    <value></value>
                  </CallVariable>
                </callvariables>
              </mediaProperties>
              <mediaType>Voice</mediaType>
              <participants>
                <Participant>
                  <actions>
                    <action>ANSWER</action>
                  </actions>
                  <mediaAddress>1072</mediaAddress>
                  <mediaAddressType>AGENT_DEVICE</mediaAddressType>
                  <startTime>2017-09-15T19:23:36.872Z</startTime> …
Run Code Online (Sandbox Code Playgroud)

c# xml linq-to-xml

0
推荐指数
1
解决办法
350
查看次数

用较小的时间尝试 Task.Delay。试图找出为什么会发生这种情况

试图了解如何使用 Task.Delay 我一直在做一系列简单的实验,我发现了以下内容。

首先我这样做了

static void Main(string[] args)
  {
     Console.WriteLine("Start");
     Task.Run(async () => {
                    Stopwatch sw = Stopwatch.StartNew();
                    await Task.Delay(2000);
                 //    for(int i=0;i<1000;i++)
                  //         await Task.Delay(2);
                     sw.Stop();
                    Console.WriteLine("Delay of {0}", sw.ElapsedMilliseconds);
                   //return sw.ElapsedMilliseconds;
                });

    Console.WriteLine("End of everything:");
    Console.ReadKey();

    }
Run Code Online (Sandbox Code Playgroud)

结果正如预期的那样延迟了 2 秒多一点。到目前为止,一切都很好!然后我注释了延迟线并取消注释了 for 循环。1000 次 2 毫秒必须给出 2 秒,对吗?错误的!这次用了15秒。

我稍后会对此发表评论,但只是为了进行比较,我这样做了。

    static void Main(string[] args)
    {
     Console.WriteLine("Start");
     Stopwatch sw = Stopwatch.StartNew();
     for (int i = 0; i < 1000; i++)
          Thread.Sleep(2);

//         Thread.Sleep(2000);
      sw.Stop();
      Console.WriteLine("Delay of {0}", sw.ElapsedMilliseconds);
      Console.WriteLine("End");

    }
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我得到了更精确的 …

c# timedelay

0
推荐指数
1
解决办法
1647
查看次数