Click here to Skip to main content
13,056,966 members (43,939 online)
Rate this:
Please Sign up or sign in to vote.
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.

Posted 27-Nov-12 16:51pm
Krunal R 27-Nov-12 22:53pm
Provide your code here...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

on page
<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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Mustafa,

following logic might help you..

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();


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170728.6 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100