I'm just wondering if it exists better solution for this.
BitConverter.ToInt32(sample_guid.ToByteArray(), 0)
I'm just wondering if it exists better solution for this.
BitConverter.ToInt32(sample_guid.ToByteArray(), 0)
Dunno about a better solution, but I hope you don't intend to use that Int32 as a random (or unique) value.
You cannot depend on any sub part of a Guid to be unique. Guid is assumed to be unique, only in its entirety.
@Ishmaeel Don't worry, it's just for handling some legacy code in my new app.
I don't know if it's better, but it is easier to read:
Int32.Parse(sample_guid.ToString().SubString(0,1));
I'm a junior developer, admittedly, but the above reads easier to me than a byte conversion, and on a modern computer it would run indistinguishably quickly.