471,319 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

using Microsoft.VisualBasic in c#

Hi friends,

Probably stupid question,

Is it wrong or dangerous if I use some vb.net functions in c# via
Microsoft.VisualBasic namespase? For example:

Int32 a = Microsoft.VisualBasic.Strings.Asc("z");

Console.WriteLine(a);

It is working, but I am wondering is it safe to use it?
Feb 16 '06 #1
5 9944
Go ahead and use 'em, it's completely safe.
Feb 16 '06 #2
It is .NET managed code and is part of the framework. Don't be afraid of the
namespace's name. Use it away.
--

Stoitcho Goutsev (100)

"Avon" <mi*********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi friends,

Probably stupid question,

Is it wrong or dangerous if I use some vb.net functions in c# via
Microsoft.VisualBasic namespase? For example:

Int32 a = Microsoft.VisualBasic.Strings.Asc("z");

Console.WriteLine(a);

It is working, but I am wondering is it safe to use it?

Feb 16 '06 #3
Its safe to use.

However, in case you wonder,the equivalent to your code in C# is:

int Asc(char ch)
{
//Return the character value of the given character
return (int)Encoding.ASCII.GetBytes(S)[0];
}
--
-Demetri
"Stoitcho Goutsev (100)" wrote:
It is .NET managed code and is part of the framework. Don't be afraid of the
namespace's name. Use it away.
--

Stoitcho Goutsev (100)

"Avon" <mi*********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi friends,

Probably stupid question,

Is it wrong or dangerous if I use some vb.net functions in c# via
Microsoft.VisualBasic namespase? For example:

Int32 a = Microsoft.VisualBasic.Strings.Asc("z");

Console.WriteLine(a);

It is working, but I am wondering is it safe to use it?


Feb 16 '06 #4
> However, in case you wonder,the equivalent to your code in C# is:

int Asc(char ch)
{
//Return the character value of the given character
return (int)Encoding.ASCII.GetBytes(S)[0];
}


Careful! ASCII is _not_ character encoding used by the Asc() function in the VB assembly... Accoring to the docs, the line should probably look something like this:

return (int)Encoding.GetEncoding(System.Globalization.Cul tureInfo.CurrentCulture..TextInfo.ANSICodePage).Ge tBytes(S)[0];
Feb 16 '06 #5

"Avon" <mi*********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
| Hi friends,
|
| Probably stupid question,
|
| Is it wrong or dangerous if I use some vb.net functions in c# via
| Microsoft.VisualBasic namespase? For example:
|
| Int32 a = Microsoft.VisualBasic.Strings.Asc("z");
|
| Console.WriteLine(a);
|
|
|
| It is working, but I am wondering is it safe to use it?
|
|

It's not wrong nor dangerous, but that doesn't mean it's the right thing to
do.
Don't forget that you will load the Microsoft.VisualBasic.dll into your
process, this is quite expensive when all you need is to call 'Asc'.

Willy.

Feb 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Abraham Andres Luna | last post: by
7 posts views Thread by David P. Donahue | last post: by
4 posts views Thread by Rainer Queck | last post: by
6 posts views Thread by =?Utf-8?B?R3JlZw==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.