Large string addition subtraction ?

I have two very long strings (150-250 digits) I need to perform math addition subtraction.

string a = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
string b = "222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222";
string c = "33333333333333333333";

string Finished = a - b + c;

These are the longest/largest numbers I've ever worked with, so I don't know if I should covert them before processing math.

I recieve this compile error:  Operator '-' cannot be applied to operands of type 'string' and 'string'      
Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
Take a look at this project entitled "C# BigInteger Class":
in 'addition', with C# the + operator, operating on strings does CONCATENATION, not 'addition' - with strings, even if made up of digits, the Strings will be APPENDED, not converted to numbers and the ADDED.


string b = "222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222";
string c = "33333333333333333333";

b+c = "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222233333333333333333333"



I do not know of any 'native' C# workspaces that can deal with 150 -250 digit INTEGERS.  What are you doing that requires the use of such large numbers?


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.