Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

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

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
indy500fan
Asked:
indy500fan
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
it is quiet easy, just use:

dim s as string
s = yourcolor.ToString()
0
 
ptakjaCommented:
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
 
indy500fanAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now