Some notes on software development... RSS 2.0
# Thursday, 14 February 2008

To convert an Icon to be used as a Bitmap you can use this function:

   
private Bitmap IconToBitmap(Icon icon)
{
    Bitmap bmp = new Bitmap(icon.Width, icon.Height);

    using (Graphics g = Graphics.FromImage(bmp))
    {
        g.DrawIcon(icon, 0, 0);
    }

    return bmp;
}

Thursday, 14 February 2008 11:49:30 (GMT Standard Time, UTC+00:00)  #    -
CF

From the manual:

DatalogicMemorResetInstructions

Thursday, 14 February 2008 08:41:24 (GMT Standard Time, UTC+00:00)  #    -
Datalogic
# Thursday, 07 February 2008
Thursday, 07 February 2008 10:35:36 (GMT Standard Time, UTC+00:00)  #    -
C#

This is a handy operator that can be used to replaces 'if-else' syntax therefore producing less code.
The operator is used in the form:

condition ? first_expression : second_expression;

If the condition is true then the first_expression is returned. If the condition is false the second_expression is returned.

For example:

if (string.IsNullOrEmpty(_name))
{
  txtName.Text = "";
}
else
{
  txtName.Text = _name;
}

can be re-written using the ternary operator like so:

txtName.Text = string.IsNullOrEmpty(_name) ? "" : _name;


Links:

MSDN ?: Operator (C# Reference)

Thursday, 07 February 2008 09:34:49 (GMT Standard Time, UTC+00:00)  #    -
C#
Navigation

Sign In
Extras
Statistics
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2018
Hadrian Phillips

All Content © 2018, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)