Convert System.Web.UI.WebControls.Unit to int in c#

前端 未结 7 1577
我在风中等你
我在风中等你 2021-01-20 15:07

How can I convert from an ASP.NET Unit structure to int in c#? Or reverse?

相关标签:
7条回答
  • 2021-01-20 15:57

    If you mean the Unit class:

    The Unit class can represent values only between -32768 and 32767.

    But it depends if you want the Pixel or Percentage value.

    • myUnit.Value will get the value as pointed out.
    • Use the constructor public Unit(int value) to convert back.

    If you mean a uint: there's 2 possible obvious ways:

    int n = Convert.ToInt32(myUint);
    int n = (int)myUint;
    

    0 讨论(0)
提交回复
热议问题