Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Char Array in C#

Posted on 2004-10-12
12
502 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

837 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