小编use*_*511的帖子

C#追加字典

我如何将词典附加到另一个词典?

Dictionary<string, DateTime> odict = new Dictionary<string, DateTime>();
        //Liste tous les Clients EMAIL (3)
        foreach (var TheClientID in TheClient.GetClient_Id(3))
        {
            Dictionary<string, DateTime> Temp = oEmail.VoirEML(TheClientID.Key);
             //odict = odict.Concat(Temp).ToDictionary(pair => pair.Key, pair => pair.Value);
            odict = odict.SelectMany(toto => Temp)
                     .ToLookup(pair => pair.Key, pair => pair.Value)
                     .ToDictionary(group => group.Key, group => group.First());
        }
Run Code Online (Sandbox Code Playgroud)

我想连续/追加字典,而不是双重条目.

c# dictionary concat append

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

从子表单设置MdiParent

我有一个主要表单,其中包含一个打开子表单的菜单:

public Le_MainForm()
{ 
  InitializeComponent();
  this.IsMdiContainer = true;
  .....
}

private void barButtonItem_CreatOrdreAller_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
  Close_AllForm();
  Program.StatusOrdre = 1;
  Program.AllerRetour = "Ordre Aller";
  Fiche_Ordre f_Fiche = new Fiche_Ordre();
  f_Fiche.MdiParent = this;
  f_Fiche.Show();
}
Run Code Online (Sandbox Code Playgroud)

效果很好,但是我从孩子那里打开另一个表格,我失去了MdiParent:

public Liste_Ordres()
{
  InitializeComponent();
  ....
}

private void Liste_DobleClic(object sender, EventArgs e)
{
  Fiche_Ordre f_Fiche = new Fiche_Ordre(gridView_Liste_Ordres.GetFocusedRowCellValue("NO_ORDRE").ToString());
  f_Fiche.ShowDialog();
}
Run Code Online (Sandbox Code Playgroud)

c# mdiparent winforms

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

SQL COUNT GROUP BY

我有这张桌子:

代码包重量
-------------------
11 2 20
12 1 45
11 1 15
12 4 15

我怎样才能得到结果:

代码包重量
-------------------
11 3 35
12 5 60

先谢谢你,Stev

sql group-by count

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

如何获取客户端计算机名称

我正在使用C#Framework 4.0 Windows窗体.我的程序安装在服务器TSE上.有11个轻客户端连接到此服务器.

当其中一个客户启动我的程序时,我怎样才能获得他的PC名称?

c# remote-desktop terminal-services thin-client

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

C#SqlDataReader关闭方法

以下哪种方法更适合关闭SqlDataReader:

 SqlDataReader reader = comm.ExecuteReader();

 while (reader.Read())
 {
 }
 reader.Close();
 reader.Dispose();
Run Code Online (Sandbox Code Playgroud)

要么

SqlDataReader reader = comm.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
}
Run Code Online (Sandbox Code Playgroud)

或者还有另一种关闭方法?

c# dao sqlcommand sqldatareader

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

以编程方式列出SQL Server的实例

我有代码来查找sql​​server的列表

 public static string[] GetSQLServerList()
        {
            SqlDataSourceEnumerator dse = SqlDataSourceEnumerator.Instance;
            DataTable dt = dse.GetDataSources();
            if (dt.Rows.Count == 0)
            {
                return null;
            }

            string[] SQLServers = new string[dt.Rows.Count];
            int f = -1;
            foreach (DataRow r in dt.Rows)
            {
                string SQLServer = r["ServerName"].ToString();
                string Instance = r["InstanceName"].ToString();
                if (Instance != null && !string.IsNullOrEmpty(Instance))
                {
                    SQLServer += "\\" + Instance;
                }
                SQLServers[System.Math.Max(System.Threading.Interlocked.Increment(ref f), f - 1)] = SQLServer;
            }
            Array.Sort(SQLServers);
            return SQLServers;
        }
Run Code Online (Sandbox Code Playgroud)

它工作正常(如果找到SQL Server),但遗憾的是它无法找到sql Express.

有谁有想法?

提前谢谢你

c# sql-server

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

C#将String转换为DateTime

我有字符串标记[5] = 8月和字符串标记[6] = 1(见图像代币)

我想转换为DateTime.

我尝试:

DateTime DateCreated = DateTime.ParseExact(tokens[5] + tokens[6], "MM-dd", CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)

c# datetime converter

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