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

前端 未结 7 1588
我在风中等你
我在风中等你 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:38

    The Value property returns a dobule, that you can convert to an integer:

    int h = (int)someControl.Height.Value;
    

    However, the conversion might not make sense for some unit types. If you don't know for certain that the unit is of a specific type, you would want to check the Type property first.

提交回复
热议问题