I have the following code in VB.Net and I'm trying to convert it to C#.
listContacts = ACT_FRAMEWORK.Contacts.GetContactsByID(Nothing, New Guid() {New Guid(ContactID)})
Below is my attempt so far:
Guid[] test = new Guid[1];
test[0] = Guid.NewGuid(ContactID);
contactList = actApp.Contacts.GetContactsByID(null, test);
The abover errors because NewGuid() takes no arguments. I have also tried.
test[0] = contactID1;
However, you can't convert from string to Guid. Can anyone help with this?
Guid.NewGuidis a method, and you're not calling that method from your VB code - you're calling the constructor accepting a string. You can call that same constructor in C#:Or if you want to make the call in one line as per your VB code:
I think it's a shame that
NewGuidhas that name rather thanCreateGuid, but such is life :(Using
Guid.Parsewill work too of course - judging by the .NET Core source code they behave extremely similarly; the constructor just handles overflow exceptions slightly differently.