Python不允许将字典用作其他字典中的键.是否有使用非嵌套字典作为键的解决方法?
更复杂的不可清除对象和我的特定用例的一般问题已经移到这里.我对用例的原始描述不正确.
假设以下代码:
foreach(Item i on ItemCollection)
{
Something s = new Something();
s.EventX += delegate { ProcessItem(i); };
SomethingCollection.Add(s);
}
Run Code Online (Sandbox Code Playgroud)
当然,这是错误的,因为所有代表都指向同一个项目.替代方案是:
foreach(Item i on ItemCollection)
{
Item tmpItem = i;
Something s = new Something();
s.EventX += delegate { ProcessItem(tmpItem); };
SomethingCollection.Add(s);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,所有代表都指向他们自己的Item.
这种方法怎么样?还有其他更好的解决方案吗?
当我说
Dictionary<int,string>
Run Code Online (Sandbox Code Playgroud)
它是否相当于两个不同的数组,例如:
int[] keys =new int[] { 1, 2, 3 };
string[] values=new string[]{"val1","val2","val3"};
Run Code Online (Sandbox Code Playgroud) 您好我想在java脚本中创建一个带有2个for循环的数组
var i;
var a;
var total = document.getElementsByName('qm[7]')
var creativity = document.getElementsByName('qm[0]');
var design = document.getElementsByName('qm[1]');
var text = document.getElementsByName('qm[3]');
var motivation = document.getElementsByName('qm[5]');
var depth = document.getElementsByName('qm[6]');
var usefulness = document.getElementsByName('qm[8]');
var research = document.getElementsByName('qm[9]');
ratingArray = new Array(total,creativity,design,text,motivation,depth,usefulness,research);
for(i=0; i < ratingArray.length;i++)
{
for(a=0; a < ratingArray[i].length;a++)
{
if(ratingArray[i][a].checked == true)
{
rateArray = new Array(ratingArray[i][a].value);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我返回rateArray它只是给出了第一个元素吗?
我今天安装了Visual Studio 2010的beta 2.我去测试新的实体框架内容(看看我的v1中的"问题"是否已修复).
我开始添加一个新的连接字符串,但是当我输入我的sql 2000信息时,它说"不支持此服务器版本.你必须拥有Microsoft sql server 2005或更高版本.".他们是否在实体框架的v2中删除了对Sql Server 2000的支持?
我目前正在尝试编写一个小服务来删除一个目录及其中包含的所有文件,有一个问题,我不知道如何解决,即用户没有访问该文件夹的权限或更新它,所以我试图从AD中以管理员身份运行删除.有什么办法可以在服务中做到这一点吗?由于服务将通过一个小脚本在系统登录上运行以启动它.
任何帮助,将不胜感激.
谢谢
它是一种非常好的公开知识,可_x0020_替换SharePoint内部字段名称中的空格.使用SharePoint Web服务时,在比较字段名称之前编写替换规则之前,这可能有点噩梦.
我刚刚在名为SSL2的字段中找到了另一个"编码异常".奇怪的是内部名称最终存在_x0053_SL2.我尝试过类似RRL2的东西_x0052_.由此看来,编码中使用的数字表示该字符的ASCII值.空间同样如此_x0020_.
我的问题是双重的:
在这种情况下,是什么导致SharePoint对这些字符进行编码.
从广义上讲,正在进行什么样的编码,我是否可以采取一般步骤来解码字符串,而不是替换我遇到的特定情况并知道这是一个问题.
我试图将文本分成单词:
$delimiterList = array(" ", ".", "-", ",", ";", "_", ":",
"!", "?", "/", "(", ")", "[", "]", "{", "}", "<", ">", "\r", "\n",
'"');
$words = mb_split($delimiterList, $string);
Run Code Online (Sandbox Code Playgroud)
用字符串工作得很好,但我遇到了一些与数字有关的情况.
例如,如果我有文本"看看这个.我的分数是3.14,我很高兴." 现在阵列是
[0]=>Look,
[1]=>at,
[2]=>this,
[3]=>My,
[4]=>score,
[5]=>is,
[6]=>3,
[7]=>14,
[8]=>and, ....
Run Code Online (Sandbox Code Playgroud)
然后3.14分为3和14,这在我的情况下不应该发生.我的意思是点应分两个字符串而不是两个数字.应该是这样的:
[0]=>Look,
[1]=>at,
[2]=>this,
[3]=>My,
[4]=>score,
[5]=>is,
[6]=>3.14,
[7]=>and, ....
Run Code Online (Sandbox Code Playgroud)
但我不知道如何避免这种情况!
任何人都知道如何解决这个问题?
Thanx,Granit
由于在C#4中修复了一个错误,将打印以下程序true.(在LINQPad中试试)
void Main() { new Derived(); }
class Base {
public Base(Func<string> valueMaker) { Console.WriteLine(valueMaker()); }
}
class Derived : Base {
string CheckNull() { return "Am I null? " + (this == null); }
public Derived() : base(() => CheckNull()) { }
}
Run Code Online (Sandbox Code Playgroud)
在VS2008的发布模式下,它会抛出InvalidProgramException.(在调试模式下,它工作正常)
在VS2010 Beta 2中,它没有编译(我没有尝试Beta 1); 我学到了很难的方法
this == null在纯C#中还有其他方法吗?
我的表单上有一个面板,AutoScroll设置为true,因此会自动显示滚动条.
如何使用户可以使用鼠标滚轮滚动面板?谢谢你.
c# ×5
dictionary ×2
ado.net ×1
arrays ×1
asp.net ×1
asp.net-4.0 ×1
compiler-bug ×1
delegates ×1
foreach ×1
javascript ×1
loops ×1
mousewheel ×1
panel ×1
php ×1
python ×1
scroll ×1
sharepoint ×1
split ×1