小编Tho*_*mas的帖子

为什么我不能初始化Map <int,String>?

我想存储一组int/ String值,但ints不一定是增量的,这意味着数据可以是:

<1, "first">, <3, "second">, <9, "third">. 
Run Code Online (Sandbox Code Playgroud)

所以我正在尝试创建一个等效的c#,Dictionary<int, string>但它只是无法编译,说"令牌上的语法错误"int",此符号后面的维度"在线上:

private Map<int, String> courses;
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么会这样?和一个很好的选择,为创建一个对象作为占位符intString,然后用一个数组来存储它们?

java generics map

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

默认的wcf服务应用程序没有定义端点

我刚刚在VS2010(Premium)中创建了一个新的WCF服务应用程序项目,它开箱即用,但是当我打开web.config文件时,没有端点存在.应用程序工作正常,我可以在浏览器中打开地址(http:// localhost:50639/Service1.svc?wsdl),我可以看到合同,这一切看起来都很好.

所以我的问题是,如果默认项目使用了不同的方法,而不是将信息放在web.config中?我也看不到代码中的任何内容.

为了表明我的观点,这就是web.config包含的全部内容:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false     and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the     value below to true.  Set to false before deployment to avoid disclosing exception     information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer> …
Run Code Online (Sandbox Code Playgroud)

c# wcf

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

获取键actionscript 3数组

使用数组和自定义键时,我在使用ActionScript3时遇到了一些麻烦.

这是我定义测试数组的方式:

var array:Array = new Array();
array[100] = "test1";
array[101] = "test2";
Run Code Online (Sandbox Code Playgroud)

现在我可以使用以下方法循环:

for each(var entry:String in array)
{
  trace(entry);
}
Run Code Online (Sandbox Code Playgroud)

这将给我以下输出:

test1
test2
Run Code Online (Sandbox Code Playgroud)

但我希望得到这些字符串属于哪个键([100] [101])

我总是可以执行for(i ...)循环并检查分配的数据,但由于这些数据可能包含0到数千及以上的密钥,这看起来很糟糕.

有没有一种很好的方法来循环这个数组,或者我应该重新设计存储一个对象并保持一个键和值?

arrays key actionscript-3

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

标签 统计

actionscript-3 ×1

arrays ×1

c# ×1

generics ×1

java ×1

key ×1

map ×1

wcf ×1