Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Translate VB to C#
Message
From
11/12/2013 10:47:38
 
 
To
11/12/2013 10:24:56
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 8
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01589830
Message ID:
01589871
Views:
38
>>>I have been given some code for VB.NET and am trying to re-write it in C# (really just as an exercise in understanding what it is trying to do) but am stuck on this line:
>>>
>>>
Dim commands As String() = alterScopeSql.Split(New String() {"GO" & vbCr & vbLf, "GO ", "GO" & vbTab, "GO"}, StringSplitOptions.RemoveEmptyEntries)
>>
>>The converter at http://www.developerfusion.com/tools/convert/vb-to-csharp gives:
>>
>>
>>string[] commands = alterScopeSql.Split(new string[] {
>>	"GO" + Constants.vbCr + Constants.vbLf,
>>	"GO ",
>>	"GO" + Constants.vbTab,
>>	"GO"
>>}, StringSplitOptions.RemoveEmptyEntries);
>>
>>
>>They are not 100% accurate sometimes but usually they do a pretty good job.
>>
>>Is that one working for you?
>
>Thanks, that is now compiling properly. I did not know about the converter, thanks for that too.
>
>Do you understand what that code does?

It splits the alterScope string into separate, presumably SQL command, lines using the 4 strings in new string[] as 'delimiters' For example, given:
            string alterScopeSql = "SELECT * FROM ORDERS GO SELECT * FROM Customers GO";
            string[] commands = alterScopeSql.Split(new string[] {"GO\r\n","GO ","GO\t","GO"}, StringSplitOptions.RemoveEmptyEntries);
then after running 'commands' would be:
[0] "SELECT * FROM ORDERS"
[1] "SELECT * FROM CUSTOMERS"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform