Click here to Skip to main content
15,918,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have some string value like B162,B161,B160,B159,B158

CSS
and i define
string test1 = B159;
string test2= B162;

than how to get all numbers between Test1 nad test2



and button event is
C#
protected void ExportBulkSql(object sender, DirectEventArgs e)
       {
           string buildFrom = B159;
           string buildTo = B162;
       }



how can i get all numbers between buildFrom nad buildTo without array
Here i do not want to use array
Posted
Updated 11-Aug-15 1:52am
v2
Comments
deepankarbhatnagar 11-Aug-15 8:08am    
Not getting your query...
Maciej Los 11-Aug-15 8:26am    
Replace "B" with empty string, convert string to integer value, make substraction operation and you'll get the count of record between given data.
jinesh sam 21-Aug-15 15:16pm    
Update the Question with Expected Answer

1 solution

C#
String buidfrom=B159;
String buildto=B162;
String buildfrmno=buildfrom.Remove(0,1);
String buildtono=buildto.Remove(0,1);

Int bfrm=int.parse(buildfrmno.Text);
Int bto=int.parse(buidto.Text);
int diff=bto-bfrm;
string btwn="";
for(int i=1;i<=diff;i++)
{
btwn="B"+(bfrm+1)+",";
}

Total number of records=diff+2;
Btwn=B160,B161,
 
Share this answer
 
v2
Comments
Maciej Los 11-Aug-15 17:41pm    
Looks lik java code, not c#...
On the second hand, i think that OP wants to get total number of records that have been affected. My comment to the question was a joke. I wanted to show that the question is unclear.
Arasappan 12-Aug-15 0:10am    
First try and say...U only joking man.. ur not need in array.. then..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900