title: How to convert string to Guid
body: <p>I have a string variable which is receiving a <code>Guid</code>. I need to convert this string back to Guid as the database field is of type <code>Guid</code>.</p>
  
  <p>I tried using:  </p>
  
  <pre><code>Guid myGuid = Guid.Empty;;
  myGuid = Guid.Parse(myId);
  </code></pre>
  
  <p>But keep getting <code>Format Exception; Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)</code>.</p>
  
  <p>Below is my code:</p>
  
  <pre><code> public string addVehicleDetails(string vname, string vtype, string regNumber, string ftype, string fefficiency, string insby, DateTime datecreated, string myId)
          {
  
              string result = string.Empty;
              tblVehicleDetail myVehicleDetails = new tblVehicleDetail();
            //  Guid myGuid = Guid.Empty;
              System.Guid myGuid = new Guid(myId);
             // myGuid = Guid.Parse(myId);
              try {
  
                 // Add details into vehicle details
                  myVehicleDetails.VehicleName = vname;
                  myVehicleDetails.VehicleType = vtype;
                  myVehicleDetails.RegistrationNumber = regNumber;
                  myVehicleDetails.FuelType = ftype;
                  myVehicleDetails.FuelEfficiency = fefficiency;
                  myVehicleDetails.InsuranceBy = insby;
  
                  myVehicleDetails.DateCreated = datecreated;
                  myVehicleDetails.Guid = myGuid;
  
                  dc.tblVehicleDetails.InsertOnSubmit(myVehicleDetails);
  
                  dc.SubmitChanges();
  
                  return result = vname;
  
              }
              catch(Exception exp)
              {
                  exp.ToString();
                  return result = "Error in Adding Vehicle Details.";
              }
          }
  </code></pre>
  
  <p>Any solution for this?</p>