microsoft.visualbasic命名空间已过时? [英] microsoft.visualbasic namespace obsolete?

查看:103
本文介绍了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()。它会给我现在需要的东西,但是我应该寻找别的东西吗?

解决方案

4月23,下午2:14,cj< c ... @nospam.nospamwrote:


我认为他们是包含在
中的过时方法
向后兼容性。例如,使用

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


< blockquote>


>我认为它们是为了向后兼容而包含的过时方法。



它们不会过时。


>是否有一些

昏暗的文件作为新的东西
dim lastchanged as date = file.datetime

我们现在应该使用的方法?



System.IO.File.GetLastWriteTime是替代方案 - 使用你最好的


Mattias


-

Mattias Sj?gren [C#MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com

请回复到新闻组。


" cj" < cj@nospam.nospamschrieb;


>我认为它们是为了向后兼容而包含的过时方法。



这是一个错误的印象。


dim file as new something

dim last changed as date = file.datetime


我们现在应该使用的方法?


如果是这样的话会让它变得更好filedatetime(" c:\ myfile.txt")???


我试图避免microsoft.visualbasic中的函数因为我想学习

做事的新方式,但经常我发现新的方式更长

,似乎更令人困惑。



没有新方法。只有不止一种方式。看看''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 for
backward compatibility. For instance is using
filedatetime("c:\myfile.txt") still the accepted way of getting the date
c:\myfile.txt was last modified? I see filedatetime is in the
Microsoft.VisualBasic namespace. Is there some

dim file as new something
dim 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 to
learn the new way of doing things but frequently I find the new way is
longer and seems more confusing. Like my example filedatetime(). It''ll
do what I need now but should I look for something else???

解决方案

On Apr 23, 2:14 pm, cj <c...@nospam.nospamwrote:

I am under the impression they are obsolete methods included for
backward compatibility. For instance is using
filedatetime("c:\myfile.txt") still the accepted way of getting the date
c:\myfile.txt was last modified? I see filedatetime is in the
Microsoft.VisualBasic namespace. Is there some

dim file as new something
dim 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 to
learn the new way of doing things but frequently I find the new way is
longer and seems more confusing. Like my example filedatetime(). It''ll
do what I need now but should I look for something else???

You''ll get a lot of different opinions on this issue. Largely, what
you should do depends on what you plan to do in the future.

If you''re planning to become a hard-core .NET developer, you should
definitely learn the .NET way of doing things. (This is especially
true if you want to learn other .NET languages.) The
Microsoft.VisualBasic namespace does include a lot of stuff that is
there to ensure that VB6 code is portable to .NET; we are encouraged
to move away from that namespace to the functionality provided by the
core System namespaces.

The real value of that depends on a number of factors. Is the code
going to be ported to other languages? Will it be used by other
systems? Is it a code library? Or is it a self-contained application
that''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 move
away from the Microsoft.VisualBasic namespaces. The payoff is
worthwhile. The C# samples that are pervasive don''t use that
namespace; you''ll find that they''re much easier to understand and port
to Visual Basic.NET if you know what they''re doing. :) Further, the
pain customary to the learning period is short-lived; once you know
it, 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


>I am under the impression they are obsolete methods included for
backward compatibility.

They are not obsolete.

>Is there some

dim file as new something
dim lastchanged as date = file.datetime

method we are supposed to use now?

System.IO.File.GetLastWriteTime is the alternative - use whatever you
like best.
Mattias

--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


"cj" <cj@nospam.nospamschrieb;

>I am under the impression they are obsolete methods included for backward
compatibility.

That''s a wrong impression.

dim file as new something
dim 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 to learn
the new way of doing things but frequently I find the new way is longer
and seems more confusing.

There is no "new way". There is only more than one way. Take a look at the
classes in the ''System.IO'' namespace, namely ''File''.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于microsoft.visualbasic命名空间已过时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆