简体   繁体   中英

how to convert a string into integer representation and change it back

I was wondering if there were any good methods to change a string into an integer representation and then be able to change the integer representation back to a string? There are a lot of ways to change a string to an integer representation by changing each character to ASCII, etc. but I was confused by how to change the ascii integer back into the fully formed string.

I am trying to represent my object of 3 strings into an integer so that I do not have to group by 3 string but just 1 integer.

For example an object of :

("hey", "hello", "goodbye")

would have an int representation of lets say 123423425 with some algorithm.

Then if possible I would like to be able convert that int from another algorithm back into

("hey", "hello", "goodbye")

Any help would be appreciated

int number = Int32.Parse("45");
string formatted = number.ToString()//add formatting if needed

You can go back and forth

Reference for format strings: http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx

Convert char array to string

char[] charArray = {'1', '2', '3'};
String str = String.valueOf(charArray);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM