I am trying to create a query. Here is the code
string wherequery = "";
int fromcode = Convert.ToInt32(CodeTextBox.Text);
int count = Convert.ToInt32(CountTextBox.Text);
for (int i = 0; i < count; i++)
wherequery += ("'" + (fromcode + i).ToString().PadLeft(8,'0') + "',");
wherequery = wherequery.TrimEnd(",");
I am using for loop to create a IN
query. Is it possible via LINQ?
Output should be
'0000000087','0000000088','0000000089'
Second thing, I get the code from a textbox value like 0000000087
. When I convert it into int using Convert.ToInt32
, preceding 0s get disappeared.
Is it possible that 0s shouldn't get disappear since number of preceding 0s may vary?