How to convert color to string and color to string

Source: Internet
Author: User

How to convert color to string and color to string

I saw a problem in the forum just now. The type "System. Drawing. Color" cannot be implicitly converted to "string ":


This problem will occur when developing website applications to json serialization. In fact, this question has already been answered in MSDN. Take a look at the following method:


For more details, see TypeConverter Class http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter (v = vs.110). aspx


How to convert strings and colors in c #

String c1 = System. Drawing. ColorTranslator. ToHtml (System. Drawing. Color. Red );
// C1 = "# ff0000"; or c1 = "Red ";

System. Drawing. Color c2 = System. Drawing. ColorTranslator. FromHtml ("# ff0000 ");

How to change the character color in word

"All characters "?
Ctrl + H
Search content: ^?
Replace with: click "advanced"-format-font color-select "blue"-OK-replace all

"All numbers ":
^? Change to ^ #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.