I want to store Color in string if they are Human Readable format and ToArgb() if they are not.
科罗公司然后将其储存在“Red”座,如果说肤色是一些绿色变体,则将其储存为“ff40ff80”。
顺便说一句,我想把这句话改成科罗语。
I want to store Color in string if they are Human Readable format and ToArgb() if they are not.
科罗公司然后将其储存在“Red”座,如果说肤色是一些绿色变体,则将其储存为“ff40ff80”。
顺便说一句,我想把这句话改成科罗语。
页: 1 http://msdn.microsoft.com/en-us/library/50cb8sdx.aspx” rel=“nofollow noreferer”>Color.ToString(
方法将适用于:
Return Value
类型:
System.String
如果使用<代码>FromName方法或
FromKnownColor
方法,以预先界定的颜色产生,则以这种颜色为名;否则,由GHB部分名称及其价值构成的说明。
Color color = Color.Red;
string colorName = color.Name; // this gives you the ability to switch back to Color through Color.FromName()
Color sameColor = Color.FromName(colorName);
和Cody 格雷人已经说,将信息从表面上抹掉是非常简单的。 问题正在重新回到表面。
因此,这可能给你某种起点。 它不是经过考验的,而是应该就如何解决这一问题提出一些想法。
public Color FromString(string name)
{
if(String.IsNullOrWhitespace(name))
{
throw new ArgumentException("name");
}
KnownColor knownColor;
if(Enum.TryParse(name, out knownColor))
{
return Color.FromKnownColor(knownColor);
}
return ColorTranslator.FromHtml(name);
}
我只记得存在几个问题,取决于肤色如何写成扼杀。 在每个框架中都有某些类别,但所有类别都在名称空间(如<代码>Color Translator)之间分配。
如你简单叫Color.FromName(Color.FromArgb(3,4,5,6),ToString()
,你用一个名字跳出一个肤色,但加固的数值是零!
我发现,上述解决办法在从科罗到扼杀和返回科罗等地都很有力。 它们取决于肤色是否事先界定,是否有一个名字。 下面的法典适用于我。
从科罗到斯特鲁:
string ConvertColorToString(Color color)
{
return Convert.ToString(color.ToArgb())
}
从扼杀到科罗:
Color ConvertStringToColor(string s)
{
return Color.FromArgb(Convert.ToInt32(s))
}
通过将彩色转换为32美特惠制的分类,在转换过程中保留了彩色属性。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...