Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

if statement c#

I have a reader but i am converting to c# from vb. what is the equivalent of.

 while (myReader.Read())
                        {
                            if (myReader(1) < 10)  << error here
                            {
                                Other = myReader.GetInt32(1);
                            }
Avatar of 13Shadow
13Shadow

The code you posted is C#. Are you asking for the vb equivalent?
Avatar of Seven price

ASKER

Yes
 Dim cIdx As Integer = -1
        Dim Other As Integer
        Dim NotProvided As Integer

  Do While sqlDR.Read
            If sqlDR("ttt") < 10 Then
                Other += sqlDR("ttt") 
            ElseIf sqlDR("ttt")  = "" Then
                NotProvided += sqlDR("ttt") 
            Else
                cIdx += 1
                ReDim Preserve yValues(cIdx)
                ReDim Preserve xValues(cIdx)
                xValues(cIdx) = sqlDR("ttt") 
                yValues(cIdx) = sqlDR("AAA") 
            End If
        Loop

        If Other > 0 Then
            cIdx += 1
            ReDim Preserve yValues(cIdx)
            ReDim Preserve xValues(cIdx)
            xValues(cIdx) = "Other"
            yValues(cIdx) = Other
        End If

        If NotProvided >= 0 Or NotProvided = "0" Then
            cIdx += 1
            ReDim Preserve yValues(cIdx)
            ReDim Preserve xValues(cIdx)
            xValues(cIdx) = "Not Provided"
            yValues(cIdx) = NotProvided
        End If

Open in new window

Even the c# code comes out as error when I use the less than sign with an integer.
SOLUTION
Avatar of 13Shadow
13Shadow

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
  List<double> yValues = new List<double>();
                    List<string> xValues = new List<string>();
  while (myReader.Read())
                        {{
 xValues.Add(Convert.ToString(myReader[0]));
                                yValues.Add(Convert.ToDouble(myReader[1]));
}
                   

Open in new window


I want to add a if statement in the code above. if myreader(0) < 10 then do something else.
got it thanks
While myReader.Read()
      If myReader(1) < 10 Then
            Other = myReader.GetInt32(1)
      End If
End While