Solved

Conversion question

Posted on 2011-02-28
8
369 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
Comment Utility
shouldn't it be whereclause.length - 5?

Ss
0
 

Author Comment

by:avi7
Comment Utility
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
Comment Utility
shouldn't you be using:

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

AW
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
Comment Utility
Paste your Sample code here
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
*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
Comment Utility
Thanks, let me try this...
0
 

Author Closing Comment

by:avi7
Comment Utility
Thanks! It is working :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

15 Experts available now in Live!

Get 1:1 Help Now