Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since you want to maintain code portability, you will need to convert your <code>GridUnit</code> into <code>TableLayoutPanelCellPosition</code> when you want to use it. You could implement static methods to do the conversion for you.</p> <pre><code>static GridUnit ConvertToGridUnit(TableLayoutPanelCellPosition position) { return new GridUnit(position.Column, position.Row; } static TableLayoutPanelCellPosition ConvertToTableLayoutPanelCellPosition (GridUnit gridUnit) { return new TableLayoutPanelCellPosition(gridUnit.Column, gridUnit.Row; } </code></pre> <p>You would use the conversion methods like this:</p> <pre><code>GridUnit homeLastPositionLast = ConvertToGridUnit(homeLastPositionFirst); </code></pre> <p>Even better, you could turn the conversion methods into conversion operators:</p> <pre><code>public static explicit operator GridUnit(TableLayoutPanelCellPosition position) { return new GridUnit(position.Column, position.Row; } public static explicit operator TableLayoutPanelCellPosition(GridUnit gridUnit) { return new TableLayoutPanelCellPosition(gridUnit.Column, gridUnit.Row; } </code></pre> <p>Then you can cast between GridUnit and TableLayoutPanelCellPosition:</p> <pre><code>GridUnit homeLastPositionLast = (GridUnit)homeLastPositionFirst; </code></pre> <p>If you wanted to allow free conversion between GridUnit and TableLayoutPanelCellPosition without explicit casting, you would change <code>explicit</code> into <code>implicit</code> in the converstion operator. Then you could do this:</p> <pre><code>GridUnit homeLastPositionLast = homeLastPositionFirst; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload