本文介绍了microsoft.visualbasic命名空间已过时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的印象是,他们已经过时的方法包含了 向后兼容性。例如,使用 filedatetime(c:\ myfile.txt)仍然是获得日期的可接受方式 c:\ myfile.txt上次修改?我看到filedatetime位于 Microsoft.VisualBasic命名空间中。是否有一些 昏暗的文件作为新的东西 dim lastchanged as date = file.datetime 方法我们现在应该使用吗? 如果是这样的话会使它比filedatetime更好(c:\ myfile.txt)??? 我试图避免使用microsoft.visualbasic中的函数,因为我想 学习新的做事方式但经常我发现新的方式是 更长时间似乎更令人困惑。就像我的例子filedatetime()。它会给我现在需要的东西,但是我应该寻找别的东西吗? 解决方案 你会在这个问题上得到很多不同的意见。很大程度上,你应该做什么取决于你打算将来做什么。 如果你打算成为一个核心人物。 NET开发人员,你应该 绝对学习.NET的做事方式。 (如果你想学习其他.NET语言,这尤其是 。) Microsoft.VisualBasic命名空间确实包含了很多东西。 确保VB6代码可移植到.NET;我们被鼓励 从该命名空间转移到 核心系统命名空间提供的功能。 真正的价值这取决于许多因素。代码 是否会被移植到其他语言?它会被其他 系统使用吗?它是一个代码库吗?或者它是一个独立的应用程序 这是一次性的,不太可能在其他任何地方使用? 实用性应该总是决定你决定做什么。然而, 实用性确实*并不意味着你应该总是戴上眼罩, 或者遭受非常狭窄的世界观。 规划未来。我的建议是你坚持下去,并从Microsoft.VisualBasic名称空间移开 。收益是值得的。值得。普遍使用的C#样本不使用那个 名称空间;如果你知道他们在做什么,你会发现他们更容易理解并将它们移植到Visual Basic.NET中。 :)此外,学习期间习惯性的痛苦是短暂的;一旦你知道 它,你就知道了它,你会对每个人都有更多的价值。 我希望我没有淹没了你。 (我有时会这样做。) 干杯! Mike Hofer 它们不会过时。 System.IO.File.GetLastWriteTime是替代方案 - 使用你最好的。 Mattias - Mattias Sj?gren [C#MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com 请回复到新闻组。 这是一个错误的印象。 没有新方法。只有不止一种方式。看看''System.IO'命名空间中的 类,即''文件''。 - MS Herfried K. Wagner MVP< URL:http://dotnet.mvps.org/> VB< URL:http:/ /dotnet.mvps.org/dotnet/faqs/> I am under the impression they are obsolete methods included forbackward compatibility. For instance is usingfiledatetime("c:\myfile.txt") still the accepted way of getting the datec:\myfile.txt was last modified? I see filedatetime is in theMicrosoft.VisualBasic namespace. Is there some dim file as new somethingdim lastchanged as date = file.datetime method we are supposed to use now? If so what would make it better than filedatetime("c:\myfile.txt")??? I try to avoid functions in microsoft.visualbasic because I want tolearn the new way of doing things but frequently I find the new way islonger and seems more confusing. Like my example filedatetime(). It''lldo what I need now but should I look for something else??? 解决方案 You''ll get a lot of different opinions on this issue. Largely, whatyou should do depends on what you plan to do in the future. If you''re planning to become a hard-core .NET developer, you shoulddefinitely learn the .NET way of doing things. (This is especiallytrue if you want to learn other .NET languages.) TheMicrosoft.VisualBasic namespace does include a lot of stuff that isthere to ensure that VB6 code is portable to .NET; we are encouragedto move away from that namespace to the functionality provided by thecore System namespaces. The real value of that depends on a number of factors. Is the codegoing to be ported to other languages? Will it be used by othersystems? Is it a code library? Or is it a self-contained applicationthat''s a one-shot and not likely going to be used anywhere else?Practicality should always govern what you decide to do. However,practicality does *not* mean that you should always have blinders on,or suffer from a very narrow world view. Plan for the future. My suggestion is that you keep at it, and moveaway from the Microsoft.VisualBasic namespaces. The payoff isworthwhile. The C# samples that are pervasive don''t use thatnamespace; you''ll find that they''re much easier to understand and portto Visual Basic.NET if you know what they''re doing. :) Further, thepain customary to the learning period is short-lived; once you knowit, you *know* it, and you''ll have much more value to everyone. I hope I haven''t overwhelmed you. (I tend to do that sometimes.) Cheers!Mike Hofer They are not obsolete. System.IO.File.GetLastWriteTime is the alternative - use whatever youlike best.Mattias --Mattias Sj?gren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.comPlease reply only to the newsgroup.That''s a wrong impression. There is no "new way". There is only more than one way. Take a look at theclasses in the ''System.IO'' namespace, namely ''File''. --M S Herfried K. WagnerM V P <URL:http://dotnet.mvps.org/>V B <URL:http://dotnet.mvps.org/dotnet/faqs/> 这篇关于microsoft.visualbasic命名空间已过时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 02:03