.NET Framework等同于ASCW& CHRW [英] .NET Framework Equivalent to ASCW & ChrW

查看:79
本文介绍了.NET Framework等同于ASCW& CHRW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的宁愿使用dot-nettified语法而不是挖掘来自Microsoft.VisualBasic的
全局函数。


任何人都知道获得相同结果的新方法吗?

-

Peace&快乐的计算,

Mike Labosh,MCSD

Musha ring dum a doo dum a da! - James Hetfield

I would really rather use the "dot-nettified" syntax rather than digging
global functions out of Microsoft.VisualBasic.

Anyone know the newfangled way to achieve the same results?

--
Peace & happy computing,

Mike Labosh, MCSD
"Musha ring dum a doo dum a da!" -- James Hetfield

推荐答案

>我真的更喜欢使用dot-nettified。语法而不是从Microsoft.VisualBasic中挖掘
>I would really rather use the "dot-nettified" syntax rather than digging
全局函数。

任何人都知道实现相同结果的新方法吗?
global functions out of Microsoft.VisualBasic.

Anyone know the newfangled way to achieve the same results?



如果你真的想要,你可以使用System.Convert类。


但是在使用ChrW / AscW之前我会三思而后行。它们是
编译时计算的表达式,导致代码比任何函数调用都更高效。

Mattias


-

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

请回复到新闻组。



Well if you really want to you can use the System.Convert class.

But I would think twice before using that over ChrW/AscW. They are
compile-time evaluated expressions that result in code that''s more
efficient than any function call ever can be.
Mattias

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


我同意。 AscW和ChrW是可靠的功能,这是最优雅的方式

来做到这一点。例如,Convert.ToInt32将执行AscW的操作,但是你需要确保你只传递一个字符 - AscW将为你提供
通过只查看第一个字符,如果你传递一个字符串。


您可以使用''纯''.NET代码编写自己的AscW和ChrW函数,但是

有什么意义? (经过严格测试的版本已经存在)

-

David Anton
www.tangiblesoftwaresolutions.com

主页:

清除VB:清理过时的VB.NET代码

即时C#:从VB.NET转换为C#

即时VB:从C#转换为VB.NET

即时J#:从VB.NET转换为J#

" Mattias Sj ?? gren"写道:
I agree. AscW and ChrW are reliable functions that are the most elegant way
to do this. For instance, Convert.ToInt32 will do what AscW does, but you
will have to ensure you''re passing exactly one character - AscW takes care of
that for you by only looking at the first character if you pass a string.

You could write your own AscW and ChrW functions using ''pure'' .NET code, but
what''s the point? (very well tested versions already exist)
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Mattias Sj??gren" wrote:
我真的宁愿使用dot-nettified。语法而不是挖掘Microsoft.VisualBasic中的全局函数。

任何人都知道获得相同结果的新方法吗?
I would really rather use the "dot-nettified" syntax rather than digging
global functions out of Microsoft.VisualBasic.

Anyone know the newfangled way to achieve the same results?



好吧,如果你真的很想你可以使用System.Convert类。

但是在使用ChrW / AscW之前我会三思而后行。它们是编译时评估的表达式,导致代码比任何函数调用都更有效。

Mattias

-
Mattias Sj ?? gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
请仅回复新闻组。



Well if you really want to you can use the System.Convert class.

But I would think twice before using that over ChrW/AscW. They are
compile-time evaluated expressions that result in code that''s more
efficient than any function call ever can be.
Mattias

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



2005-08-30,David Anton< Da ******** @ discussion.microsoft.com>写道:
On 2005-08-30, David Anton <Da********@discussions.microsoft.com> wrote:
我同意。 AscW和ChrW是可靠的功能,是执行此操作的最优雅方式。例如,Convert.ToInt32将执行AscW所做的事情,但是你必须确保你只传递一个字符 - AscW通过仅查看第一个字符来处理
你传递了一个字符串。
I agree. AscW and ChrW are reliable functions that are the most elegant way
to do this. For instance, Convert.ToInt32 will do what AscW does, but you
will have to ensure you''re passing exactly one character - AscW takes care of
that for you by only looking at the first character if you pass a string.




这不是马蒂亚斯所指出的。虽然在Strings命名空间中有名为AscW和ChrW的函数,但函数调用

不一定是你输入AscW(C)时得到的函数代码。

相反,它们是编译时表达式,导致不同的
编译代码,具体取决于您发送给它们的参数类型。 (我

我真的不知道该怎么称呼它们,它们的功能就像关键词,但是

它们不是关键词)。

相当于ChrW函数调用的是System.Convert.ToChar()。

AscW更有趣。真的有.Net等价,因为

最多.Net语言不需要函数调用,但是当你指向

out时,Convert.ToInt32将使用单个

字符或多或少地做同样的事情。



That''s not exactly what Mattias was pointing out. While there are
functions named AscW and ChrW in the Strings namespace, that function call
is not necessarily what you get when you type AscW("C") into your code.
Rather, they are compile time expressions that result in different
compiled code depending on what parameter types you send to them. (I
don''t really know what to call them, they function like keywords, but
they aren''t keywords).

The equivalent to the ChrW function call is System.Convert.ToChar().
AscW is more interesting. There really isn''t a .Net equivalent since
most .Net languages don''t need a function call here, but as you point
out, Convert.ToInt32 will do more or less the same thing with single
characters.

您可以使用'编写自己的AscW和ChrW函数' '纯''.NET代码,但
You could write your own AscW and ChrW functions using ''pure'' .NET code, but


有什么意义? (已经存在经过良好测试的版本)


what''s the point? (very well tested versions already exist)




好​​吧,如果你多次切换.Net语言或在多语言商店工作,

远离VisualBasic命名空间和

VB转换关键字是有利的。它是一个巨大的命名空间,有许多有用的

函数,它们与.Net的main

命名空间相似但不完全相同。如果你在语言中使用相同的功能,那么你不必担心细微的差别。



Well, if you switch .Net languages a lot or work in a multi-language shop,
there''s an advantage to staying away from the VisualBasic namespace and
the VB conversion keywords. It''s a huge namespace with many useful
functions that are similar but not quite identical to the "main"
namespaces of .Net. If you use the same functions across languages,
then you don''t have to worry about the subtle differences.


这篇关于.NET Framework等同于ASCW&amp; CHRW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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