Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 27-Nov-12 16:51pm
Comments
Krunal R at 27-Nov-12 22:53pm
   
Provide your code here...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

on asp.net 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
}
}
  Permalink  
v2
Rate this: bad
good
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();
 
--SRJ
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 430
1 DamithSL 288
2 Sergey Alexandrovich Kryukov 220
3 Peter Leow 215
4 Maciej Los 195


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