Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How can i convert c# 'uint' to 'int'

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 19-05-2009
Member
 
Join Date: Jan 2009
Posts: 124
How can i convert c# 'uint' to 'int'
  

I would like to know that how can i convert convert c# 'uint' to 'int' on my system. Can any body provide me the correct logical solution for the above issue? Does any body knows that how to convert 'uint' to 'int' by using C# programming language? Kindly provide me the correct information on the above issue. Any kind of help on the above issue would be appreciated.

Reply With Quote
  #2  
Old 19-05-2009
Member
 
Join Date: May 2008
Posts: 2,291
Re: How can i convert c# 'uint' to 'int'

When an integer literal has no suffix, its type is the first of these types in which its value can be represented: int, uint, long, ulong. In this example, it is uint.

You can also use the suffix u or U, like this:
Quote:
uint myUint = 123U;
When you use the suffix U or u, the literal type is determined to be either uint or ulong according to its size. In this example, it is uint.
Reply With Quote
  #3  
Old 19-05-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How can i convert c# 'uint' to 'int'

In order to do this, you'll need to convert each element in a loop. You need to do the following code for doing so.

Quote:
private byte[] ConvertFromUInt32Array(UInt32[] array)
{
List<byte> results = new List<byte>();
foreach(UInt32 value in array)
{
byte[] converted = BitConverter.GetBytes(value);
results.AddRange(converted);
}
return results.ToArray();
}
Reply With Quote
  #4  
Old 02-06-2009
Member
 
Join Date: Jun 2009
Posts: 1
ThumbsUp Re: How can i convert c# 'uint' to 'int'

This code:
uint x = 5;
int y = (int)x;
Console.WriteLine("The value of int y is {0}",y.ToString());
produces this output:
The value of int y is 5
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How can i convert c# 'uint' to 'int'"
Thread Thread Starter Forum Replies Last Post
How do I convert .DMG to .ISO? xxsniper1522 Windows Software 2 13-10-2010 06:47 AM
Convert m4v to dvd advsnhal Windows Software 2 29-07-2009 09:05 AM
How to convert pub to pdf Gretel Windows Software 2 19-05-2009 11:33 PM
Place a uint > 255 in a buffer Elijah Software Development 4 06-04-2009 11:40 PM
Convert video to iPod, Convert iTunes video, Convert DivX to MP4 tommyhills MediaCenter 1 26-07-2008 02:30 AM


All times are GMT +5.5. The time now is 12:39 PM.