小编roc*_*mar的帖子

c#中list <>和dictionary <>有什么区别?

我对c#中的列表和字典有一个奇怪的疑问

在列表中,我们使用以下方法将项目添加到列表中

using System.Collections.Generic;

class Program
{
    static void Main()
    {
       List<int> list = new List<int>();
       list.Add(2);
       list.Add(3);
       list.Add(5);
       list.Add(7);
    }
}
Run Code Online (Sandbox Code Playgroud)

在字典中我们添加这样的项目......

using System;
using System.Collections.Generic;

class Program
{
   static void Main()
   {
      Dictionary<string, int> d = new Dictionary<string, int>();
      d.Add("cat", 2);
      d.Add("dog", 1);
      d.Add("llama", 0);
      d.Add("iguana", -1);
   }
}
Run Code Online (Sandbox Code Playgroud)

我不确切地知道有什么区别,但是在字典中我们添加像(键,值)对的项目,在列表中我们只是添加项而不指定任何键.

有人会澄清这个吗?

.net c# dictionary list winforms

16
推荐指数
3
解决办法
4万
查看次数

两个条件检查where子句使用linq 2 entites

嗨,我有一个名为带列的产品的表

                 product_id
                 prodcut_name
                 prodcut_price( values like 1200,2000,3000,100)
                 prodcut_desc
                 category_id(1,2,3,.....) 
Run Code Online (Sandbox Code Playgroud)

带列的anorther表类别

              category_id(1,2,3.......)
              category_name(a,b,c....)
Run Code Online (Sandbox Code Playgroud)

和实体名称是dbcontext ...

如何获得类别名称为"a"且产品价格> 500且<10000的产品

我正在使用linq来实现...

会不会对此有所帮助......一个......

非常感谢....

.net c# linq linq-to-entities entity-framework

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

如何将datetime列拆分为日期和时间并单独进行比较

我有一张访问桌

与列

            member_id
           visit_id
           visit_logout_datetime(values like this... '
Run Code Online (Sandbox Code Playgroud)

现在我需要将visit_logout_datetime与今天的日期时间属性进行比较...

这是两个条件

1)我需要compare the today date with date来自这个字段visit_logout_datetime

//这里我想做点什么......

2)我需要比较 present time with the time in this field visit_logout_datetime

我想个别比较..

我怎样才能做到这一点 ..

任何人都会对此有所帮助....

mysql sql

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

标签 统计

.net ×2

c# ×2

dictionary ×1

entity-framework ×1

linq ×1

linq-to-entities ×1

list ×1

mysql ×1

sql ×1

winforms ×1