vb equivalent in cs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
the following snippet works in vb but i'm missing the syntax in csharp:

String val1 = values.Split(",")(1);

i'm getting this error:

Argument '1': cannot convert from 'string' to 'char[]'

thanks,
rodchar
 
In both VB and C#, arrays start at 0. The only difference is that in VB you
declare an array size by specifying the upper bound, which is the size less
one.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter


Jack Hughes said:
don't c# array subscripts start at zero rather than one in VB?

so, the equivalant would be:

string val1 = values.Split(',')[0];

Jack

Mark said:
String val1 = values.Split(",")(1);
string val1 = values.Split(',')[1];
 
Try this one,

String val1 = values.Split(",")[1];

Cause we obtain indexed elements value(index) at Visual Basic
but in C# value[index] gives correct result.

rodchar yazdi:
 
No!!!!!!!

It's the "," parameter to the Split method. That is a string but it needs a
char, change it to ','. The single quotes indicates that it is a char
literal instead of a string literal.

string val1 = values.Split(',')[1];


dursun caglar said:
Try this one,

String val1 = values.Split(",")[1];

Cause we obtain indexed elements value(index) at Visual Basic
but in C# value[index] gives correct result.

rodchar yazdi:
hey all,
the following snippet works in vb but i'm missing the syntax in csharp:

String val1 = values.Split(",")(1);

i'm getting this error:

Argument '1': cannot convert from 'string' to 'char[]'

thanks,
rodchar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top