A method to see if something exists?
Posted on 2006-04-07
I have a method FindElementsGuid and I call it like this
Guid gElementGuid = myschema.FindElementsGuid(sElementReference);
But I want to find out if a Guid exists or not.
Would I be better writing a method 'ElementHasAGuid' (which would return a boolean) or can I get that information somehow?
/// Find the elements guid with the given fullname using a breadth-first search through the hierarchy. Throws an exception if the element can't be found.
/// <param name="fullname">Fullname to search for</param>
public Guid FindElementsGuid(string fullname)
foreach (Element oElement in AllElements)
if (oElement.FullName == fullname)
throw new ApplicationException("Couldn't find Elements Guid with Fullname '" + fullname.ToString() + "'.");