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

How can I convert from an ASP.NET Unit structure to int in C #? Or vice versa?

+3
source share
7 answers

A device type has a Value property . It is double, but you can use it for int if you want. Casting can lead to a loss of accuracy, but you probably know about it.

To create a block, use a constructor that takes an int .

+11
source

If you mean the Unit class :

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

, Pixel Percentage.

  • myUnit.Value .
  • public Unit(int value) .

uint: 2 :

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

a >

+3

Unit.Value. , int

- (int)xyz.Value

WEhere xyz -

int , new Unit(value)

+1

ASP.NET:

unit.IsEmpty ? 0 : Convert.ToInt32(unit.Value);
+1

, :

 int myInt = 1;
 uint myUint = (uint)myInt;

 uint myUint = 1;
 int myInt = (int)myUint;
0

Value dobule, :

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

. , , Type.

0
Convert.Toint32( UInt );

I assume u means UInt not Unit

EDIT: Well, I thought you meant uint sorry

-1
source

Source: https://habr.com/ru/post/1745941/


All Articles