提前致歉;我正在尝试学习C#的第3天。
我被指示建立字典的哈希表;没问题。我看到那已经建立。我现在需要遍历哈希集,如果字典的键!=特定字符串,则将条目复制到新列表中。有人可以解释一下完成此看似简单任务的正确语法吗?
var goodSongs = new List<Dictionary<string,string>>();
var allSongs = new HashSet<Dictionary<string, string>>();
Dictionary<string, string> meatloaf = new Dictionary<string, string>();
meatloaf.Add("Meatloaf", "Paradise By The Dashboard Light");
Dictionary<string, string> aerosmith = new Dictionary<string,string>();
aerosmith.Add("Aerosmith", "Cryin'");
Dictionary<string, string> nickelback = new Dictionary<string, string>();
nickelback.Add("Nickelback", "Rockstar");
allSongs.Add(nickelback);
allSongs.Add(aerosmith);
allSongs.Add(meatloaf);
//foreach loop to iterate dictionaries goes here
Run Code Online (Sandbox Code Playgroud)
目标-要摆脱困境,希望学习C#,并决定我是否要继续努力下去。谢谢大家。
我不明白为什么我会收到这个错误。我正在尝试从映射的配置文件的 appSettings 部分获取值。
这是我的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</configSections>
<appSettings>
<!-- Need to configure.-->
<add key="ServiceDisplayName" value="Scheduler-aaaa" />
<add key="ServiceName" value="SchedulerService-aaaa" />
<add key="SchedulerTime" value="05:00 AM" />
<!-- 12 hour format-->
<add key="RoutingInterval" value="5"/>
<add key="ADSyncInterval" value="2"/>
<add key="ReportPath" value="C:\inetpub\wwwroot\aaaa\Reports\DefaultReports"/>
<add key="ReportPathCustom" value="C:\inetpub\wwwroot\aaaa\Reports\CustomReports"/>
<add key="ApplicationUrl" value="https://mms.com/aaaa/"/>
<add key="ServiceUrl" value="https://temp.com/aaaa/Inspection/Service"/>
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="EmailAddress" value="support@mms.com" />
</appSettings>
<connectionStrings>
<add name="CustomerDB" connectionString="Provider=SQLOLEDB.1;Data Source=.\temp;User ID=mm;PWD=mm;Initial Catalog=35testupdate" />
</connectionStrings>
<cachingConfiguration />
<startup> …Run Code Online (Sandbox Code Playgroud)