Easy C# question about Guids
Posted on 2013-11-07
I am taking SharePoint dev courses about SP workflows and the assumption is that I have already mastered C#, which i have not, I only have a decent understanding of the principles. So the course keeps on pulling a rabbit out of a hat, so to speak, without explanation. So I might have many more questions like this ion the future, but hopefully they will all be easy points for everyone.
I understand what default(Guid) does after some research, and the course code used this in another exercise
public Guid varname = default(Guid);
But now in this exercise, when it is declaring a field to hold a Guid value it is:
public Guid workflowId = default(System.Guid);
At first I thought it needed System.Guid instead of just Guid because I have no using statement at the top for System.Guid, so in this case, it has to be explicit. So when I went to add using System.Guid, intellisense does not know what I am talking about. I have read that Guid is in the System namespace, so I thought that maybe I need to add a reference to System.Guid, but under .net, I cannot find any such reference.
So what's going on?
Also, inside of an event handler, it calls this
taskID = Guid.NewGuid();
I understand that the Guid has a static method called NewGuid, which does not create an empty guid like in the case of the field variable declaration above, but instead generates an actual Guid value. But I don't understand how this method could just seemingly be called out of nowhere right after a Guid value type. Does it have something to do with the fact that taskID has already been declared as a Guid field/variable?