Solved

Char Array in C#

Posted on 2004-10-12
12
499 Views
Last Modified: 2008-03-10
Hi,

I am beginner to C#. Can someone show me an example where program is accepting two numbers upto 256 digits using char arrays and then adding those two numbers using C#.

I would really appreciate help on this.

Arpita
0
Comment
Question by:aparmar
12 Comments
 
LVL 8

Expert Comment

by:Razzie_
ID: 12290443
Sounds like homework. Why do you want it done that way?
0
 

Author Comment

by:aparmar
ID: 12290587
yes it is a homework. Its program that accepts two numbers of 256 digits each and after accepting two numbers it adds those two. Is there another way of doing it?

Thanks

arpita
0
 

Author Comment

by:aparmar
ID: 12290644
I can write simple program declaring two integer variable but my only problem is 256 digits limit.

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 14

Expert Comment

by:AvonWyss
ID: 12290696
Well, use a byte - not a char. A char in the .NET world is unicode and thus not 8 bits anyways, apart from not being a numeric type alltogether.
0
 
LVL 3

Accepted Solution

by:
a_goat earned 125 total points
ID: 12294649
OK, basically don't think of it as character arrays.  Use two strings to read in the values.  Then you have to remember your old grade school addition:

345678
+24601
---------
370279

Just start from the end of each string and add the two numbers together (you can convert the characters to numbers in a number of ways, my favorite is (byte)NextCharacter - 48)  Don't forget to handle the case where you have to carry a one over to the next column.  Build your result string as you go.

Was that vague enough to pass EE guidelines yet specific enough to help?
0
 

Author Comment

by:aparmar
ID: 12298767
Thanks goat. This helps. It answers my question. all I needed was a guideline not a solution.
Thank You.
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12512513
Goat solved the question... see author comment 10/13/2004 04:52PM CEST
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# if statement weird reaction 3 30
C# Connection String for Oracle database is not working 22 51
C# TextBox 11 15
Birthdays 3 21
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now