本文介绍了Rectangle.FromString()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我仍然在C#周围寻找方向,我不确定什么是可能的,而不是 可能。有没有办法做相当于 Rectangle r = new Rectangle(); r.FromString(anotherRectangle.ToString()); 并假设没有,小组会建议我用FromString方法创建我自己的 Rectangle类或覆盖ToString给予 更易解析的东西,或者是什么? 谢谢, Andrew 解决方案 我认为在 之外实现这个功能会更好矩形结构(显然)也没有新的Rectangle。我在这里假设是,当然,所讨论的功能受到限制 可以从外部完成相当简单的事情,比如字符串 你想要的转换。在这种情况下,我认为这将是一个更好的方法 有一个RectangleStringConverter或者介绍你自己的 不可互换的矩形替换。 Oliver Sturm - 提供专家编程和咨询服务 参见 http://www.sturmnet.org (尝试/博客) I''m still finding my way round C# and am not sure what is possible and notpossible. Is there any way to do the equivalent of Rectangle r = new Rectangle();r.FromString(anotherRectangle.ToString()); and assuming there isn''t, would the panel recommend I create my ownRectangle class with a FromString method or override the ToString to givesomething a bit more parsable, or what? Thanks, Andrew 解决方案 I think it would be better to implement this function outside of theRectangle structure (obviously) and also without a new Rectangle. I''massuming here, of course, that the functionality in question is restrictedto fairly simple stuff that can be done from the outside, like the stringconversion you want. In that case I think it would be a better approach tohave a RectangleStringConverter or something than to introduce your ownnon-interchangable Rectangle replacement.Oliver Sturm--Expert programming and consulting services availableSee http://www.sturmnet.org (try /blog as well) 这篇关于Rectangle.FromString()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 14:49