472,094 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,094 software developers and data experts.

convert hybridDictionary to string

Hi all

I have a shopping cart object which I'd like to send the contents via an
e-mail.

I get an error saying 'hybridDictionary' cannot be converted to string.

Does anyone know how to do this or point me in the right direction?

Thanks
Jul 1 '06 #1
4 1829
If you could convert a dictionary into a string, it would end up as one
long string of values, without line breaks or anything. That's probably
not what you want anyway.

Create a StringBuilder, loop through the items in the dictionary and add
the text for each item to the StringBuilder.

James Page wrote:
> Hi all

I have a shopping cart object which I'd like to send the contents via an
e-mail.

I get an error saying 'hybridDictionary' cannot be converted to string.

Does anyone know how to do this or point me in the right direction?

Thanks
Jul 1 '06 #2
Thanks for your reply.

Could you give an example of a "string builder" I'm fairly new to asp.net 2.0
"Göran Andersson" wrote:
If you could convert a dictionary into a string, it would end up as one
long string of values, without line breaks or anything. That's probably
not what you want anyway.

Create a StringBuilder, loop through the items in the dictionary and add
the text for each item to the StringBuilder.

James Page wrote:
Hi all

I have a shopping cart object which I'd like to send the contents via an
e-mail.

I get an error saying 'hybridDictionary' cannot be converted to string.

Does anyone know how to do this or point me in the right direction?

Thanks
Jul 2 '06 #3
Ok, here goes:

// Create a StringBuilder
StringBuilder builder = new StringBuilder();

// Add some text
builder.Append("Some text.");

// Add an integer
int answer = 42;
builder.Append(answer);

// Add a line break
builder.AppendLine();

// Things like dates and floating point values should be formatted
builder.AppendFormat("yyyy-MM-dd HH:mm:ss", DateTime.Now);

// You can stack appends
builder.Append("Number ").Append(answer).AppendLine(" again");

// Finally get the complete string
string message = builder.ToString();

James Page wrote:
Thanks for your reply.

Could you give an example of a "string builder" I'm fairly new to asp.net 2.0
"Göran Andersson" wrote:
>If you could convert a dictionary into a string, it would end up as one
long string of values, without line breaks or anything. That's probably
not what you want anyway.

Create a StringBuilder, loop through the items in the dictionary and add
the text for each item to the StringBuilder.

James Page wrote:
>>Hi all

I have a shopping cart object which I'd like to send the contents via an
e-mail.

I get an error saying 'hybridDictionary' cannot be converted to string.

Does anyone know how to do this or point me in the right direction?

Thanks
Jul 3 '06 #4
Thanks Göran I'll try that

James

"Göran Andersson" wrote:
Ok, here goes:

// Create a StringBuilder
StringBuilder builder = new StringBuilder();

// Add some text
builder.Append("Some text.");

// Add an integer
int answer = 42;
builder.Append(answer);

// Add a line break
builder.AppendLine();

// Things like dates and floating point values should be formatted
builder.AppendFormat("yyyy-MM-dd HH:mm:ss", DateTime.Now);

// You can stack appends
builder.Append("Number ").Append(answer).AppendLine(" again");

// Finally get the complete string
string message = builder.ToString();

James Page wrote:
Thanks for your reply.

Could you give an example of a "string builder" I'm fairly new to asp.net 2.0
"Göran Andersson" wrote:
If you could convert a dictionary into a string, it would end up as one
long string of values, without line breaks or anything. That's probably
not what you want anyway.

Create a StringBuilder, loop through the items in the dictionary and add
the text for each item to the StringBuilder.

James Page wrote:
Hi all

I have a shopping cart object which I'd like to send the contents via an
e-mail.

I get an error saying 'hybridDictionary' cannot be converted to string.

Does anyone know how to do this or point me in the right direction?

Thanks
Jul 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Paul | last post: by
3 posts views Thread by Convert TextBox.Text to Int32 Problem | last post: by
3 posts views Thread by William Stacey [MVP] | last post: by
1 post views Thread by Paul Tomlinson | last post: by
7 posts views Thread by patang | last post: by
6 posts views Thread by patang | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.