Seven price
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);
}
while (myReader.Read())
{
if (myReader(1) < 10) << error here
{
Other = myReader.GetInt32(1);
}
The code you posted is C#. Are you asking for the vb equivalent?
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
ASKER
Even the c# code comes out as error when I use the less than sign with an integer.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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]));
}
I want to add a if statement in the code above. if myreader(0) < 10 then do something else.
ASKER
got it thanks
While myReader.Read()
If myReader(1) < 10 Then
Other = myReader.GetInt32(1)
End If
End While
If myReader(1) < 10 Then
Other = myReader.GetInt32(1)
End If
End While