|
Estarta wrote: my question wasn't so clear
Certainly not.
Estarta wrote: i was trying to tell u guys i want the answer without parsing the input into integers.
You never even clearly stated that the input is the string representation of an integer. By the way, there is no way I can think of that wouldn't require you to do some parsing. You cannot do mathematical computations with strings.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
private void Button1_Click(object sender, System.EventArgs e)
{
int x= int.Parse(Input.Text);
int sum = 0;
while (x > 0)
{
sum += x % 10;
x /= 10;
}
Output.Text=sum.ToString();
}
how about this one?
Estarta
|
|
|
|
|
Estarta wrote: how about this one?
Computes the sum of the digits of the number entered in Input control, but I gues you already know that. What is the actual question here.
By the way, you should surround the Parse operation with a try-catch-block to catch the FormatException thrown when the Input control does not contain a valid string representation of an integer (or use TryParse when programming for Framework version > 1.1).
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Estarta wrote: i`m a software engineer we didn't took PROGRAMMING LANGUAGES as u did !! we only took the software engineering syuff and rational rose!!
What kind of crazy Software Engineering course did you do? The university I went to offered SoftEng courses and they included C++ and COBOL (it was a while ago) in the curriculum.
|
|
|
|
|
COBOL - almost a good anagram.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
try out
public void sumOfInt(int num)
{
int tot =0;
string nubstr = num.ToString();
for(int y=0;y < nubstr.Length; y++)
{
int sub = int.Parse(nubstr.Substring(y,1));
tot=tot+sub;
}
MessageBox.Show("Sum of Integers"+" "+tot.ToString());
}
rahul
|
|
|
|
|
Thanks buddy
Estarta
|
|
|
|
|
Alternatively without using strings at all:
public int CrossSum(int value) {
int sum = 0;
while (value > 0) {
sum += value % 10;
value /= 10;
}
return sum;
}
Frankly, Estarta, if you are applying for a job as a programmer, you should be able to write something simple as this yourself.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thats true. Thanks
Estarta
|
|
|
|
|
Are you referring to the digital root of a number?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I'm trying to make a dragdrop function that I can use to move part of the text value of a TextBox to another TextBox. But I can't find any documentation how I should do this. The only thing I found was an example showing how to move the complete text value (with dragdrop) and not a part of the text. Does anyone here know how to do this?
By the way, I wouldn't mind using a RichTextBox instead of a TextBox if that would simplify things. Maybe I could use the AutoDragDrop function of the RichTextBox, but I only want to dragdrop text, I don't want anything else dragable on the controls.
Thanks,
Eelco
|
|
|
|
|
Somehow , i even have an example uploaded here:
http://gidsfiles.googlepages.com/DragDrop.cs[^]
Look at this part of the code:
private void label1_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
this.DoDragDrop(this.label1.Text, DragDropEffects.Copy);<br />
}
It sends the label1.Text , thats all the text from the label. If you want only a part then specify that there:
this.DoDragDrop(this.label1.Text.Substring(5), DragDropEffects.Copy);<br />
Or if you want the text selected in Textbox1 to goto textbox2 then
this.DoDragDrop(textBox.SelectedText, DragDropEffects.Copy);
Hope i helped
Gideon
|
|
|
|
|
hi all,
i have a checklistbox,i know how to use it as multiple rowed checkboxes,
now i need to add a lable to it,
i mean i need to desplay a lable and a (default)checkbox,
please help me
thnx in advance
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Hi to All,
Could Any one help me? How to get string data from noise string image file using c#? What should I do?
Please help me,
Advance thanks,
Ramana AV
|
|
|
|
|
A.Venkata ramana wrote: noise string image file
What is a "noise string image file"?
|
|
|
|
|
noise string image file means captcha image.
captcha image is similar to when we register any website,a captcha image will be generated dynamically with some text on captcha image.
we have some captcha images with us, our requirement is get the string data from captcha image.
Ramana AV
|
|
|
|
|
try reading them by eye.
Russell
|
|
|
|
|
I have placed a filesystemwatcher in a windows service application.
In the filesystemwatcher_created event I have placed a function to do some processing...
The idea is that when the windows service starts, the filesystemwatcher_created event should be triggered .
Any thoughts please?
Not sure what to place in the OnStart event of the windows service itself.
Thanks
|
|
|
|
|
arkiboys wrote: The idea is that when the windows service starts, the filesystemwatcher_created event should be triggered .
No. The FileSystemWatcher's created event is fired when a file / directory is created under the directory to which the FileSystemWatcher is attached.
BTW what actually you want to do ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
hi,
i want a free software with code which fulfills my following requirement:
1) maintain master records in SQL-Employees,products,company,customers
2) calculate payroll according to the sales of the sales representative
3) reports -sales of salesman,sales acc. to products,sales lead
4) payroll should have TA & DA also
5)acc. to the travel and tour plan expenses should be added to payroll
6) sale document should have products sale listing.
|
|
|
|
|
Wrong forum to ask for software recommendation, of course if you're planning to write this yourself then:
1) SQL Express
2) C# Program
3) C# Program
4) C# Program
5) C# Program
6) C# Program
|
|
|
|
|
Good luck with that. This is a very lucrative market area with a lot of regulation around it (country dependent as well), so I seriously doubt that there will be a robust, up to date, free solution that provides source code as well.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
any one know how to handle the inbound call using the c#.net
if any code for that than mail me
at keyur_1180@yhoo.com.
thank you.....
|
|
|
|
|
|