473,216 Members | 1,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 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 10123
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ben Wan | last post by:
VB.Net Rename function allow a file to be renamed or moved. How can I do something similar in C# given that the rename function is not available in C#?
0
by: Shaun | last post by:
I have read a number of resources that explain that the MyServices found in VB.NET2005 can be used in C# by adding a reference to Microsoft.VisualBasic.dll and then using the...
4
by: Abraham Andres Luna | last post by:
how can i use the DateAndTime module in my csharp code i included a using statement: using Microsoft.VisualBasic; and then called the function: DateAndTime.MonthName(1);
7
by: David P. Donahue | last post by:
Greetings, I'm using a relatively old release of Visual Studio .NET and am running into a compatability problem with one of my ASP .NET websites. From what I've gathered from support of the...
15
by: Phill. W | last post by:
Is anyone writing VB.Net (2003) code /without/ referencing the Microsoft.VisualBasic namespace(?), regardless of whether its Import'ed or not? The Powers That Be here are trying to introduce a...
1
by: Tom Kearney | last post by:
Hi - I'm trying to use "Microsoft.VisualBasic.Logging.FileLogTraceListener" from a set of C# aspx web pages, but I can't seem to use: <%@ Import Namespace="Microsoft.VisualBasic.Logging" %> I...
4
by: Rainer Queck | last post by:
Hello NG, are there any limitations to be considered, if I make use of objects in the Microsoft.VisualBasic namespace? Regards Rainer Queck
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have two questions with regards to the LEFT function. I ran into a problem with the LEFT function today. I knew it was a valid Function, but when I tried to use it, it was getting interpreted...
1
by: yawesome | last post by:
I am using Microsoft.VisualBasic.Devices.Network to download a file from a server to a PC and am receiving a 404 error. The file is in teh download location but it has 0kb. Does anyone have any...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.