堆栈克隆问题:.NET错误或预期的行为? [英] Stack Clone Problem: .NET Bug or Expected Behaviour?
本文介绍了堆栈克隆问题:.NET错误或预期的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我克隆一摞......不知道,如果它是一个.NET错误或预期的行为时,遇到了这个问题。意见?
昏暗myStack作为新的堆栈(整数)({2,1,3})
回复于(的string.join(,,myStack.Clone)及&所述峰; br>中&安培;的string.join(,,myStack.Clone.Clone))
输出:
2,1,3
3,1,2< - 我的预期2,1,3
解决方案
这是不是一个净的Bug。该的栈(T)
类型并不拥有一种克隆
方法或属性。这表现在以下code不上标准VB.Net控制台项目编译
昏暗堆栈作为新的堆栈(整数)({2,1,3})
Console.WriteLine(的string.join(,,stack.Clone))
在克隆
方法被绑定到必须在项目中的某处定义的扩展方法。该缺陷或设计行为躺在那里。
I came across this problem when cloning a stack... not sure if it's a .NET bug or expected behaviour. Opinions?
Dim myStack As New Stack(Of Integer)({2,1,3})
Response.Write(String.Join(",",myStack.Clone) & "<br>" & String.Join(",",myStack.Clone.Clone))
output:
2,1,3
3,1,2 <- I expected 2,1,3
解决方案
This is not a .Net Bug. The Stack(Of T)
type doesn't posses a Clone
method or property. This is demonstrated by the following code which doesn't compile on a standard VB.Net console project
Dim stack As New Stack(Of Integer)({2, 1, 3})
Console.WriteLine(String.Join(",", stack.Clone))
The Clone
method being bound to must be an extension method defined somewhere in your project. The bug or by design behavior lies there.
这篇关于堆栈克隆问题:.NET错误或预期的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文