/// <summary> /// Tries to parse a string and create a new BsonObjectId. /// </summary> /// <param name="s">The string value.</param> /// <param name="value">The new BsonObjectId.</param> /// <returns>True if the string was parsed successfully.</returns> public static bool TryParse(string s, out BsonObjectId value) { ObjectId objectId; if (ObjectId.TryParse(s, out objectId)) { value = new BsonObjectId(objectId); return(true); } else { value = null; return(false); } }
public static bool TryParse(string s, out BsonObjectId value) { // don't throw ArgumentNullException if s is null ObjectId objectId; if (ObjectId.TryParse(s, out objectId)) { value = new BsonObjectId(objectId); return(true); } else { value = null; return(false); } }