How to convert the C# code below to VB.NET?

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

How to convert the C# code below to VB.NET? thank you.

AddLogicalDrive(((char)('A' + i)).ToString() + ":");
 
Just judging from what you're trying to do, I'd do
AddLogicalDrive((Asc("A"c) + i).ToString() + ":")

P.S.
Also, to use a char as literal in code you use a 'c'... So,
"A"c
is a Char, not a String.

P.P.S.
I don't understand why you're casting the entire ('A'+1) expression to a
char and then to string but I'm not an expert in all things C#.
 
David,
AddLogicalDrive((ChrW(Asc("A"c) + i)).ToString() & ":")


It is the best answer of course until now and probably the way a good
converter will make it like this, however I find this kind of questions
always funny.

In my idea there has to be a kind of check if the indexer "i "cannot be less
then 0 and more then 26, at that moment the chr should be enoug althoug I
would normaly also advice to use the chrw. In other words as you don't use
the ascW there is no need to use the chrW.

I know what you can write, however it is not critique, I was just curious
about the answers and in this case there was something where this did aply,

Cor
 
Thanks for pointing that out Cor.
We are currently correcting Instant VB to be able to better detect the need
to use ChrW and AscW to simulate C# 'character math', and this inconsistency
(using ChrW, but not AscW) needs to be addressed.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to Ruby
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI
 
Back
Top