Saturday, 14 September 2013

Color to RGB and hex Value

HexConverter
 
DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
    Color c=colorDialog1.Color;
    string HexConverter= "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}

RGBConverter

DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
    Color c=colorDialog1.Color;
    string HexConverter= "RGB(" + c.R.ToString() + "," + c.G.ToString() + "," + c.B.ToString() + ")";
}

Tuesday, 10 September 2013

C# array null/empty string values

String[] URL= {"1","2","","4","6",""};

var temp = new List<string>();
foreach (var s in URL)
{
         if (!string.IsNullOrEmpty(s))
         {
              temp.Add(s);
}
URL = temp.ToArray();