如何更改字典中多个键的值.
我有以下字典:
SortedDictionary<int,SortedDictionary<string,List<string>>>
Run Code Online (Sandbox Code Playgroud)
如果键值大于某个量,我想循环遍历此排序字典并将键更改为键+ 1.
我一定做错了.我在Visual Studio 2008中有一个C#项目.突然间我看到了我的类的锁定,当我将类名称悬停在顶部选项卡上时,我看到类名称为:C:\ Myprojects\Oder.cs [只读] ]!
有什么奇怪的事情发生在你之前吗?
我认为这并不复杂,但经过一些研究后,我找不到一个简单问题的答案.
我正在迭代字典中的键,我想在一些计算中使用键作为双字符串.
如果我这样做:
foreach (KeyValuePair<string, List<string> price in dictionary)
double ylevel = Convert.ToDouble(price.Key);
Run Code Online (Sandbox Code Playgroud)
它似乎不起作用,我得到一个"输入字符串格式不正确"错误.
什么是从钥匙中获得双倍的正确方法..
谢谢
伯纳德
我正在关注Rob Conery MVC店面教程系列,并且我从以下构造函数public SqlCatalogRepository(DB dataContext)获得了一个不一致的可访问性错误:
public class SqlCatalogRepository : ICatalogRepository
{
DB db;
public SqlCatalogRepository()
{
db = new DB();
//turn off change tracking
db.ObjectTrackingEnabled = false;
}
public SqlCatalogRepository(DB dataContext)
{
//override the current context
//with the one passed in
db = dataContext;
}
Run Code Online (Sandbox Code Playgroud)
以下是错误消息:错误1可访问性不一致:参数类型"SqlRepository.DB"比方法"Data.SqlCatalogRepository.SqlCatalogRepository(SqlRepository.DB)"更难访问
我必须复制一个字典,使用该副本并返回原始字典.
似乎发生的事情是,当我对复制的字典做一些工作时,修改了orignal字典.
这是我的代码:
dmodified_profile = new SortedDictionary<int,SortedDictionary<string,List<string>>>(d_profile);
Run Code Online (Sandbox Code Playgroud)
我不知道为什么如果我在dmodified_profile字典上进行修改,可以修改原始的d_profile?
谢谢