Solved

Conversion question

Posted on 2011-02-28
8
372 Views
Last Modified: 2012-08-13
Hi,
I have a following cod in VB and I am trying to convert it to C#... Thanks!

  WhereClause = " where " & Strings.Mid(WhereClause, 6)

  WhereClause = " where " + WhereClause.Substring(5, WhereClause.Length);

I am getting the following error for C# part:
ArgumentOutOfRangeException was unhandled by user code
Index and length must refer to a location within the string.
Parameter name: length
0
Comment
Question by:avi7
8 Comments
 
LVL 9

Assisted Solution

by:sshah254
sshah254 earned 25 total points
ID: 35003874
shouldn't it be whereclause.length - 5?

Ss
0
 

Author Comment

by:avi7
ID: 35003888
I am getting this:
Error Operator '-' cannot be applied to operands of type 'string' and 'int'
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 25 total points
ID: 35003915
shouldn't you be using:

WhereClause = " where " + WhereClause.Substring(5, WhereClause.Length - 5);

AW
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 35003917
Paste your Sample code here
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35004067
You can just do:

    WhereClause = " where " & WhereClause.Substring(5)

*But this assumes that WhereClause has at least six characters in it.

To be safe:

    if (WhereClause.Length >= 6)
    {
        WhereClause = " where " & WhereClause.Substring(5)
    }
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 35004070
*I forgot the semicolons ";" on the ends of the lines though!

    if (WhereClause.Length >= 6)
    {
        WhereClause = " where " & WhereClause.Substring(5);
    }
0
 

Author Comment

by:avi7
ID: 35004082
Thanks, let me try this...
0
 

Author Closing Comment

by:avi7
ID: 35040263
Thanks! It is working :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why, and when, to use Windows Workflow 1 32
XML & .net 5 41
Code works but I need to redo it and assign values to Model 7 33
Help with C#, MVC, razor. 6 23
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now