Solved

Conversion question

Posted on 2011-02-28
8
376 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 35003917
Paste your Sample code here
0
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

808 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