Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

I have Some problem, may be its logical, please help me, the problem is that, that I have a simple page with a Textbox and a Button, actually User's are allowed to enter some comma separated numbers(like 43, 12, 213, 32, 12). Now, when submit, on the back end, I applied some formula in which the greater and lower value required to subtract or also in other words I want to get the input number separately(one by one).

Please Help me or if there is a better way so tell me.

Thanks
Posted
Comments
[no name] 27-Nov-12 22:53pm    
Provide your code here...

on asp.net page
XML
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
               <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />



________

code behind

protected void Button1_Click(object sender, EventArgs e)
{
string[] numberArray = TextBox1.Text.ToString().Split(',');

for(int i =0 ; i < numberArray.Length -1; i++)
{
// number compare logic here
}
}
 
Share this answer
 
v2
Hi Mustafa,

following logic might help you..

C#
string textbox ="23,35,45,65,75";
string[] input = textbox.Split(',');
int length = input.Length;
int[] result = new int[length];
for(int i=0; i< length;i++)
  result[i] = Convert.ToInt32(input[i]); ;
int difference = result.Max() - result.Min();


--SRJ
 
Share this answer
 

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