Results 1 to 4 of 4

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

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,302

    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:
    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.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,394

    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.

    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();
    }

  4. #4
    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

Similar Threads

  1. How do I convert .DMG to .ISO?
    By xxsniper1522 in forum Windows Software
    Replies: 2
    Last Post: 13-10-2010, 06:47 AM
  2. Convert m4v to dvd
    By advsnhal in forum Windows Software
    Replies: 2
    Last Post: 29-07-2009, 09:05 AM
  3. How to convert pub to pdf
    By Gretel in forum Windows Software
    Replies: 2
    Last Post: 19-05-2009, 11:33 PM
  4. Place a uint > 255 in a buffer
    By Elijah in forum Software Development
    Replies: 4
    Last Post: 06-04-2009, 11:40 PM
  5. Replies: 1
    Last Post: 26-07-2008, 02:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •