Tag Archives: csharp

Attributes related to WinForms Designer

  1. BrowsableAttribute
    This attribute tells designer, whether the associated property should be displayed.
  2. DefaultEventAttribute
    This attribute tells designer, if double clicked a component, which event it should generate code for.
  3. DefaultValueAttribute
    This attribute indicates the default value for the property. If you donate a value not equals default value, it will be displayed in bold.
  4. DesignerCategoryAttribute
    This attribute tells designer it belongs to what category.
  5. DesignerSerializationVisibilityAttribute
    This attribute tells designer how to serialize the associated property.
  6. DesignTimeVisibleAttribute
    This attribute tells designer whether the component should be displayed in toolbox.

To be continued…

How to use default parameter in C# 2.0 & 3.5

For example, I need a method like this:

public void InitData(int index, object value, bool required = false) {}

I can write it as:

The attribute Optional tells compiler that the parameter required has default value. And the attribute DefaultParameterValue(false) tells compiler what is the default value.

Very simple. Isn’t it?