473,406 Members | 2,281 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,406 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 10142
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.