Guid.Parse () or new Guid ()?

7

What is the main difference between using the options Guid.Parse() or new Guid() to convert a string into a Guid ?

And which of the two approaches would be best to use?

var usuarioId = new Guid(User.Identity.GetUserId())

Or

var usuarioId = Guid.Parse(User.Identity.GetUserId())

    
asked by anonymous 12.04.2018 / 15:03

1 answer

7

Essentially none except for the fact that one is a constructor and the other is a manufacturing method.

Source Builder .

Factory Method Source (this is called of the original just above its source, just checking to see if the string is valid). Note that the code already uses C # 7.x optimizations

In both the parse is the internal TryParseGuid() .

    
12.04.2018 / 15:12