Hello all.
I am developing a code in which I need to convert int to string. Plz help...
Printable View
Hello all.
I am developing a code in which I need to convert int to string. Plz help...
Hi,
Like this:
Regards,Code:String number;
int x = 10;
number = x.ToString();
Laitinen
Or
Code:int x = 10;
string xstring = Convert.ToString(x);
MessageBox.Show(xstring);
This is the code...
asset_file_list += "\n<asset size=" + asset_file_size + " count=" + asset_file_count + ">\n";
here i want that "asset_file_list" variable should get the value like
<asset size="517361" count="11">
but its giving...
<asset size=517361 count=11>
Plz check and give support...
Code:asset_file_list += "\n<asset size=" + asset_file_size.ToString() + " count=" + asset_file_count.ToString() + ">\n";
This is not working...Giving the same output as above mensioned. I tried this earlier...
Do you really want the output to look like this:
<asset size="517361" count="11">
assuming that asset_file_size and asset_file_count is already a string,
otherwise do this:Code:asset_file_list += "\n<asset size=" + "\"" + asset_file_size + "\"" + " count=" + "\""+ asset_file_count + "\"" + ">\n";
Code:asset_file_list += "\n<asset size=" + "\"" + asset_file_size.ToString() + "\"" + " count=" + "\""+ asset_file_count.ToString() + "\"" + ">\n";
you've got to wonder how some folks make it out of bed given gravity's strong pull...
When I am using
-----------------------------------------------------------------------------------------------------
asset_file_list += "\n<asset size=" + "\"" + asset_file_size + "\"" + " count=" + "\""+ asset_file_count + "\"" + ">\n";
----------------------------------------------------------------------------------------------------
I am getting the output:
"\n<asset size=\"10911\" count=\"1\">\n"
When I am using
-----------------------------------------------------------------------------------------------------
asset_file_list += "\n<asset size=" + "\"" + asset_file_size.ToString() + "\"" + " count=" + "\""+ asset_file_count.ToString() + "\"" + ">\n";
----------------------------------------------------------------------------------------------------
I am getting the output:
"\n<asset size=\"10911\" count=\"1\">\n"
Expected output:
<asset size="10911" count="1">
Where are you getting that output? If you see it in the debug window, then you have to take a look at the "Text Visualizer" and I am sure you will get the expected result.
This code works perfect in a multiline textbox;
Regards,Code:string asset_file_list = "";
int asset_file_size = 517361;
int asset_file_count = 11;
asset_file_list += "\r\n<asset size=\"" + asset_file_size.ToString() + "\" count=\"" + asset_file_count.ToString() + "\">\r\n";
textBox1.Text = asset_file_list;
Laitinen
are you perhaps looking in the watch window and not at your actual output???
Thank you all...Problem is solved...
For anyone who's curious about the fastest way to convert an int to a string, you can read this webpage (http://cc.davelozinski.com/c-sharp/f...-int-to-string).
Basically it's a toss up between:
.ToString()
Convert.ToString()
until you get to about 21 million conversions.
The code is there too if you want to run it on your own system.
Good luck!