小编Ehs*_*bar的帖子

在组合框中输入的字符串格式不正确

我有一个Drop Down ListDDL当索引更改时,我需要我的值。所以我这样做:

 private void CMBGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
           int id=int.Parse(CMBGroup.SelectedValue.ToString());
           //do something with id
       }
Run Code Online (Sandbox Code Playgroud)

form load我获取我的数据:

        goodGroups=objGoodGroupRepositoy.GetAll().ToList();
        CMBGroup.DataSource = goodGroups;
        CMBGroup.ValueMember = "Id";
        CMBGroup.DisplayMember = "Name";
Run Code Online (Sandbox Code Playgroud)

我的数据库中有这样的数据:

id serial    name
1   121    g1
2   123    g2
Run Code Online (Sandbox Code Playgroud)

但是我在加载表单之前遇到了这个错误:

Input string was not in a correct format
Run Code Online (Sandbox Code Playgroud)

我在得到这个错误在这里indexchange的事件DDL

int id=int.Parse(CMBGroup.SelectedValue.ToString());
Run Code Online (Sandbox Code Playgroud)

该模型 :

public partial class GoodGroup
    {
        public GoodGroup()
        {
            this.Goods = new HashSet<Good>();
        }

        public int Id { get; …
Run Code Online (Sandbox Code Playgroud)

c# parsing converter winforms

2
推荐指数
1
解决办法
2220
查看次数

aforge.net中的过滤器不支持源像素格式

我正在尝试使用开发LPR系统Aforge.net,我想对图像应用滤镜,如下所示:

            Bitmap a = new Bitmap(@"C:\Users\Public\Pictures\Sample Pictures\1.png");
            SobelEdgeDetector filter = new SobelEdgeDetector();
            filter.ApplyInPlace(a);
            pictureBox1.Image = a;
Run Code Online (Sandbox Code Playgroud)

但是运行后我得到了这个错误:

Source pixel format is not supported by the filter.
Run Code Online (Sandbox Code Playgroud)

我在aforge.net中是新手。

c# image bitmap image-processing accord.net

2
推荐指数
1
解决办法
5217
查看次数

使用函数计算c#中数组之间的欧几里得距离

我想计算用户输入的点之间的欧式距离,因此您可以在这里看到:

static void Main(string[] args)
{
    int numtest = int.Parse(Console.ReadLine());
    int[,] points=new int[10,2];
    for (int i = 0; i < numtest; i++)
    {
        Console.WriteLine("point " +(i+1).ToString()+" x: ");
        points[i, 0] = int.Parse(Console.ReadLine());
        Console.WriteLine("point " + (i + 1).ToString() + " y: ");
        points[i, 1] = int.Parse(Console.ReadLine());
    }
}

public float[] calculate(int[,] points)
{
    for (int i = 0; i <points.Length ; i++)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

C#中有任何功能可以做到这一点吗?

我需要数组中所有点之间的每个距离值

c# distance

2
推荐指数
2
解决办法
6316
查看次数

使用readbinary时导致流不可读

我试图通过套接字发送一个值.所以我在我的项目客户端和服务器中有两个部分.

客户端使用以下代码向服务器发送值:

  NetworkStream networkStream = socketForServer.GetStream();
            System.IO.BinaryWriter binaryWriter =
               new System.IO.BinaryWriter(networkStream);

            //------
            int messageSource = 0;
            int messageDesitination = 0;
            int interlockingId = 0;
            int trackId = 0;
            int trainId = 2;
            int direction = 0;
            int messageType = 0;
            int informationType = 0;
            int dateTime = 0;

foreach (Sensor LeftSensorList in LeftSensor)
                {

                    binaryWriter.Write(messageSource);
                    binaryWriter.Write(messageDesitination);
                    binaryWriter.Write(interlockingId);
                    binaryWriter.Write(trackId);
                    binaryWriter.Write(trainId);
                    binaryWriter.Write(direction);
                    binaryWriter.Write(messageType);
                    binaryWriter.Write(informationType);
                    binaryWriter.Write(dateTime);

                    binaryWriter.Flush();
                    binaryWriter.Close();
                    Thread.Sleep(4000);

                }
Run Code Online (Sandbox Code Playgroud)

在服务器部分我应该读取二进制值:

static void Listeners()
        {

            Socket socketForClient = tcpListener.AcceptSocket();
            if (socketForClient.Connected)
            {

                NetworkStream …
Run Code Online (Sandbox Code Playgroud)

c# sockets binaryreader binarywriter

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

用分隔符读取文本文件中的所有行

我有一个包含以下内容的文件:

1,2,3,4,5#
1,2,3,4,5#
Run Code Online (Sandbox Code Playgroud)

我如何阅读所有使用readline的线?重要的是我需要分隔每一行中的值,我的意思是第一行的值1,2,3,4,5应该分开.

假设我有一个名为myarray可以保存第一行中所有值的数组:数组应该是这样的:

myarray[0]=1
myarray[1]=2
myarray[2]=3
myarray[3]=4
myarray[4]=5
Run Code Online (Sandbox Code Playgroud)

我在IO中的IO很新#

最好的祝福

c# readline text-files

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

获取<>与其中的动态数字之间的值

我正在研究一种文本摘要方法,对于测试我的方法我有一个基准调用doc 2007,在这个基准测试中我有很多xml文件,我应该清除该文件.

例如,我有一个xml这样的文件:

<sentence id='s0'>
 The nature of the proceeding 

1 The principal issue in this proceeding is whether the Victorian Arts Centre falls within the category of 'premises of State Government Departments and Instrumentalities', for the purposes of provisions in industrial awards relating to rates of payment for persons employed in cleaning those premises.</sentence>

<sentence id='s1'>In turn, this depends upon whether the Victorian Arts Centre Trust, a statutory corporation established by the Victorian Arts Centre …
Run Code Online (Sandbox Code Playgroud)

c# regex string match

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

删除重复的行

我想在SQL Server中删除我的重复值.所以我找到了一个可以找到它们的查询,如何将delete语句附加到此查询中以删除它们?

(SELECT
    DocumentNumber, LineNumber, SheetNumber, Unit, COUNT(*)
FROM
    Lines
GROUP BY
    DocumentNumber, LineNumber, SheetNumber, Unit
HAVING 
    COUNT(*) > 1)
Run Code Online (Sandbox Code Playgroud)

sql-server

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

无法加载文件或程序集"video.player.net.dll"或其依赖项之一.找不到指定的模块.":"video.player.net.dll

我在c#windows窗口中开发LPR我使用onvif连接到相机,所以我将需求dll添加到我的项目中,你可以看到 在此输入图像描述

我的项目成功构建,但是当我运行我的项目时,我收到此错误:

{"无法加载文件或程序集'video.player.net.dll'或其依赖项之一.找不到指定的模块.":"video.player.net.dll"}

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) …
Run Code Online (Sandbox Code Playgroud)

.net c# dll onvif

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

检查节点是否存在于XDocument中

我有这个xml:

<Rejectedparameters>
  <parameter>
    <name>CO</name>
    <value>5.34</value>
  </parameter>
  <parameter>
    <name>CO2</name>
    <value>10.1</value>
  </parameter>
  <parameter>
    <name>HC</name>
    <value>473</value>
  </parameter>
  <parameter>
    <name>O2</name>
    <value>2</value>
  </parameter>
</Rejectedparameters>
Run Code Online (Sandbox Code Playgroud)

我需要检查一个节点是否存在 - 像这样:

  int Gvalue = (from x in document.Elements("Rejectedparameters").Elements("parameter")
                from p in x.Elements("Name")
                where x.Element("CO").Value.ToString() != string.Empty
                select x).Count();
Run Code Online (Sandbox Code Playgroud)

但是Gvalue是0 - 为什么?如您所见,CO它存在于XML中.

c# xml

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

在sql server中选择1700万条记录非常慢

我尝试选择一个包含 1700 万条记录的表。大约需要10分钟。在这里您可以看到实时执行计划。

在此输入图像描述

这是我的表结构:

CREATE TABLE [bas].[GatewayReceipt](
    [Id] [INT] IDENTITY(1,1) NOT NULL,
    [CustomerId] [INT] NULL,
    [UserId] [INT] NOT NULL,
    [RefNumber] [NVARCHAR](200) NULL,
    [ResNumber] [NVARCHAR](200) NULL,
    [Price] [DECIMAL](18, 5) NOT NULL,
    [GatewayChannelId] [INT] NOT NULL,
    [StatusId] [INT] NOT NULL,
    [EntryDate] [DATETIME] NOT NULL,
    [ModifyDate] [DATETIME] NULL,
    [RowVersion] [TIMESTAMP] NOT NULL,
 CONSTRAINT [PK_Bas_GatewayReceipt] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [FG_ATS]
) ON [FG_ATS]
GO
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请注意,我在 …

sql-server indexing sql-execution-plan

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