C# change the first 32bit Int of a GUID

Code Pope

I have a GUID which I created with GUID.NewGUID(). Now I want to replace the first 32 bit of it with a specific 32-bit Integer while keeping the rest as they are.
Is there a function to do this?

Aboc

You can use ToByteArray() function and then the Guid constructor.

byte[] buffer = Guid.NewGuid().ToByteArray();
buffer[0] = 0;
buffer[1] = 0;
buffer[2] = 0;
buffer[3] = 0;

Guid guid = new Guid(buffer);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Identity change GUID to int

From Dev

32bit C program no longer converting char to int on 64 bit OS Linux

From Dev

C# How to Remove leading 0's from 32bit int

From Dev

how to extract the 4 bytes of a 32bit int in lua

From Dev

Will an int be 32bit and a long 64bit regardless of whether the system is 32 or 64 bit?

From Dev

Will an int be 32bit and a long 64bit regardless of whether the system is 32 or 64 bit?

From Dev

Code First migration from int to Guid primary key issue

From Dev

bit change from 32bit JPG to 14bit grayscale My math is wrong

From Dev

Cannot build 32bit Mongo DB C++ Driver

From Dev

How to generate random 32bit integers in c++

From Dev

How can I change an int ID column to Guid with EF migration?

From Dev

break a 32bit integer, and use the second half 16bit to form an int

From Dev

break a 32bit integer, and use the second half 16bit to form an int

From Dev

GCC fprintf: should that be an int (32bit) or char (8bit)?

From Dev

constructing 32 bit unsigned int in c

From Dev

How to get the first 11 bits of a 32 bit int with ctypes

From Dev

32bit (int) Buffer to Greyscale/Colour-mapped Image in OpenGL, Single Channel 32 bit Texture or TBO?

From Dev

Different casting of int to guid in C# and SQL Server

From Dev

Mapping a related table into an IDictionary<Guid, Tuple<String, Int32>>

From Dev

Using 32bit dlls with 64bit dlls in c++

From Dev

C++ Binary Writing/Reading on 32bit to/from 64bit

From Dev

Convert C++ dll from 32bit to 64bit in MS VC 2013 Express

From Dev

Inline 64bit Assembly in 32bit GCC C Program

From Dev

C++ GetProcAddress 64bit returns 32bit address

From Dev

C++ Binary Writing/Reading on 32bit to/from 64bit

From Dev

Convert C++ dll from 32bit to 64bit in MS VC 2013 Express

From Dev

C++ Build 32bit binary on 64bit system

From Dev

C++ windows code links in 64bit but not in 32bit

From Dev

Running 32bit Orwell Dev-C++ on 32bit Win8 with 64bit CPU - incerementing pointer returns incorrect result

Related Related

  1. 1

    Identity change GUID to int

  2. 2

    32bit C program no longer converting char to int on 64 bit OS Linux

  3. 3

    C# How to Remove leading 0's from 32bit int

  4. 4

    how to extract the 4 bytes of a 32bit int in lua

  5. 5

    Will an int be 32bit and a long 64bit regardless of whether the system is 32 or 64 bit?

  6. 6

    Will an int be 32bit and a long 64bit regardless of whether the system is 32 or 64 bit?

  7. 7

    Code First migration from int to Guid primary key issue

  8. 8

    bit change from 32bit JPG to 14bit grayscale My math is wrong

  9. 9

    Cannot build 32bit Mongo DB C++ Driver

  10. 10

    How to generate random 32bit integers in c++

  11. 11

    How can I change an int ID column to Guid with EF migration?

  12. 12

    break a 32bit integer, and use the second half 16bit to form an int

  13. 13

    break a 32bit integer, and use the second half 16bit to form an int

  14. 14

    GCC fprintf: should that be an int (32bit) or char (8bit)?

  15. 15

    constructing 32 bit unsigned int in c

  16. 16

    How to get the first 11 bits of a 32 bit int with ctypes

  17. 17

    32bit (int) Buffer to Greyscale/Colour-mapped Image in OpenGL, Single Channel 32 bit Texture or TBO?

  18. 18

    Different casting of int to guid in C# and SQL Server

  19. 19

    Mapping a related table into an IDictionary<Guid, Tuple<String, Int32>>

  20. 20

    Using 32bit dlls with 64bit dlls in c++

  21. 21

    C++ Binary Writing/Reading on 32bit to/from 64bit

  22. 22

    Convert C++ dll from 32bit to 64bit in MS VC 2013 Express

  23. 23

    Inline 64bit Assembly in 32bit GCC C Program

  24. 24

    C++ GetProcAddress 64bit returns 32bit address

  25. 25

    C++ Binary Writing/Reading on 32bit to/from 64bit

  26. 26

    Convert C++ dll from 32bit to 64bit in MS VC 2013 Express

  27. 27

    C++ Build 32bit binary on 64bit system

  28. 28

    C++ windows code links in 64bit but not in 32bit

  29. 29

    Running 32bit Orwell Dev-C++ on 32bit Win8 with 64bit CPU - incerementing pointer returns incorrect result

HotTag

Archive