?
Solved

VB to C#

Posted on 2011-02-26
5
Medium Priority
?
238 Views
Last Modified: 2012-05-11
Hi,
I have a following code that I have a few problems with… I am trying to find if where is a C# equivalent for InStr, Split and Replace methods. Thanks!

else if ((Array1.Text != "") && (Array2.Text == ""))
{    
  Array2.Text = CustomerArray;
  string[] Array1Values;

 if (InStr(CustomerArray, "ML")) <--- error
 {
       string AccountNo;
       string Amount;

       Array1Values = Split(CustomerArray, ",", -1, CompareMethod.Text); <--- error

       AccountNo = Array1Values[1].ToString();
       Amount = Array1Values[2].ToString();

         Label1.Text = "Account No:";
         Label2.Text = AccountNo;
         Label3.Text = "Amount:";

         Amount = Replace(Amount, "$", "");  <---error
         Label4.Text = Amount;
        }
 }
0
Comment
Question by:avi7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 2000 total points
ID: 34988522
In C#, there is some difference. This code is not completely corrected, but I believe you will get something from this
        else if ((Array1.Text != "") && (Array2.Text == ""))
        {
            Array2.Text = CustomerArray;
            string[] Array1Values;

            if ( CustomerArray.Contains("ML")) // <--- error 
            {
                string AccountNo;
                string Amount;

                Array1Values =  CustomerArray.Split("," ); // <--- error

                AccountNo = Array1Values[1].ToString();
                Amount = Array1Values[2].ToString();

                Label1.Text = "Account No:";
                Label2.Text = AccountNo;
                Label3.Text = "Amount:";

                Amount = Amount.Replace("$", "");  // <---error
                Label4.Text = Amount;
            }
        }

Open in new window

0
 

Author Comment

by:avi7
ID: 34988588
Thanks!
But for the following line: Array1Values =  CustomerArray.Split("," );
I still receive error message: The best overloaded method match for 'string.Split(params char[])' has some invalid arguments
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34988621
Try this correction for that line
  Array1Values =  CustomerArray.Split(Convert.ToChar(",") );

Open in new window

0
 

Author Comment

by:avi7
ID: 34988707
Thanks a lot!
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34988769
Glad to help you!
Raj
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

719 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