Solved

I can convert a string to color, but how do I convert a color to string (to store it in XML)

Posted on 2008-06-21
3
372 Views
Last Modified: 2010-05-18
Friends,

I am using an XML file to store user settings for my app.  This method has worked great until I tried to deal with colors.

Now, I know I can convert a String to a color.. xmlAltRowColor = Color.FromName(xmlReader.ReadString)

But how do I convert a Color to a string?

Syntax Help Requested.  

Thanks in advance!

Best Regards,
Eric
0
Comment
Question by:indy500fan
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 21838218
it is quiet easy, just use:

dim s as string
s = yourcolor.ToString()
0
 
LVL 14

Expert Comment

by:ptakja
ID: 21861409
Jaime_olivares has the correct answer.

In fact, you can convert almost any object into a string using the .ToString method. I believe that the .ToString method is part of the System.Object class which is the base class for everything in .NET.

I say "almost" because some user-created classes may not be coded to support the .ToString method. But all .NET Framework classes do.

For example, take an Integer value x which has a value of 5

Dim x As Integer = 5

x.ToString will return "5"
0
 

Author Comment

by:indy500fan
ID: 21861446
jaime_olivares,

I am so sorry, I forgot all about this.  I used your solution, but forgot to award points.

ptakja, yes I agree, and I implemented Jaime's solution, I just forgot to give Jaime points.

Regards,
Eric
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now