Click here to Skip to main content
16,007,472 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.UInt32 -> Integer Pin
El'Cachubrey28-Sep-04 0:35
El'Cachubrey28-Sep-04 0:35 
GeneralAddTabType for PropertyGrid Pin
Claudia Peschke27-Sep-04 23:38
Claudia Peschke27-Sep-04 23:38 
GeneralRe: AddTabType for PropertyGrid Pin
leppie28-Sep-04 0:37
leppie28-Sep-04 0:37 
QuestionHow to program outlook express in C# ? Pin
ppp00127-Sep-04 22:44
ppp00127-Sep-04 22:44 
GeneralSystem.UInt32 -> Integer Pin
El'Cachubrey27-Sep-04 22:40
El'Cachubrey27-Sep-04 22:40 
GeneralRe: System.UInt32 -> Integer Pin
exhaulted27-Sep-04 23:04
exhaulted27-Sep-04 23:04 
GeneralRe: System.UInt32 -> Integer Pin
Colin Angus Mackay27-Sep-04 23:51
Colin Angus Mackay27-Sep-04 23:51 
GeneralRe: System.UInt32 -> Integer Pin
Colin Angus Mackay27-Sep-04 23:48
Colin Angus Mackay27-Sep-04 23:48 
So long as the values are in the range 0 to 2147483647 then there are no problems.

If you exceed the upper value the operation overflows. For instance: (int)UInt32.MaxValue results in -1 (negative one). This does NOT throw an exception.

If you need an exception to be thrown you can wrap the casting operation inside a checked statement.

Consider this code:
// Initial value
uint a = UInt32.MaxValue;
Console.WriteLine("a = {0}", a);

// cast to int
int b = (int)a;
Console.WriteLine("b = {0}", b);

// cast to int with an System.OverFlowException if out of range
int c = checked((int)a);
Console.WriteLine("c = {0}", c);


Does this help?


Do you want to know more?

Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!


Questionhow to insert into table throw datagrid Pin
Mikel Fayad27-Sep-04 21:38
Mikel Fayad27-Sep-04 21:38 
AnswerRe: how to insert into table throw datagrid Pin
exhaulted27-Sep-04 21:59
exhaulted27-Sep-04 21:59 
AnswerRe: how to insert into table throw datagrid Pin
exhaulted27-Sep-04 23:22
exhaulted27-Sep-04 23:22 
GeneralDial up program Pin
Connie Connie27-Sep-04 20:32
Connie Connie27-Sep-04 20:32 
GeneralRichTextBox Flickering Pin
Member 139683327-Sep-04 17:55
Member 139683327-Sep-04 17:55 
GeneralRe: RichTextBox Flickering Pin
leppie27-Sep-04 23:29
leppie27-Sep-04 23:29 
GeneralC# and C++ interop question Pin
Werdna27-Sep-04 16:58
Werdna27-Sep-04 16:58 
GeneralRe: C# and C++ interop question Pin
BAIJUMAX27-Sep-04 17:48
professionalBAIJUMAX27-Sep-04 17:48 
GeneralRe: C# and C++ interop question Pin
Werdna28-Sep-04 1:55
Werdna28-Sep-04 1:55 
GeneralRe: C# and C++ interop question Pin
shaileshkumar27-Sep-04 22:45
shaileshkumar27-Sep-04 22:45 
GeneralRe: C# and C++ interop question Pin
Werdna28-Sep-04 1:58
Werdna28-Sep-04 1:58 
GeneralRe: C# and C++ interop question Pin
shaileshkumar28-Sep-04 2:01
shaileshkumar28-Sep-04 2:01 
Generalwizard style in windows form app Pin
Cholillo27-Sep-04 16:47
Cholillo27-Sep-04 16:47 
GeneralDataGrid Column Colors Pin
MarkMokris27-Sep-04 15:57
MarkMokris27-Sep-04 15:57 
GeneralRe: DataGrid Column Colors Pin
sreejith ss nair27-Sep-04 20:46
sreejith ss nair27-Sep-04 20:46 
GeneralC# and Scanner Pin
GA-BOYZ27-Sep-04 15:17
GA-BOYZ27-Sep-04 15:17 
GeneralRe: C# and Scanner Pin
Alex Korchemniy27-Sep-04 16:40
Alex Korchemniy27-Sep-04 16:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.