diff --git a/MatFileHandler/IMatFile.cs b/MatFileHandler/IMatFile.cs index da30d72..f961286 100755 --- a/MatFileHandler/IMatFile.cs +++ b/MatFileHandler/IMatFile.cs @@ -20,5 +20,13 @@ namespace MatFileHandler /// /// Variable name. IVariable this[string variableName] { get; set; } + + /// + /// Gets the variable with the specified name. + /// + /// The name of the variable to get. + /// When this method returns, contains the variable with the specified name, if it is found; otherwise, null. + /// True if the file contains a variable with the specified name; otherwise, false. + public bool TryGetVariable(string name, out IVariable? variable); } } \ No newline at end of file diff --git a/MatFileHandler/MatFile.cs b/MatFileHandler/MatFile.cs index ec17aab..4b01602 100755 --- a/MatFileHandler/MatFile.cs +++ b/MatFileHandler/MatFile.cs @@ -34,5 +34,11 @@ namespace MatFileHandler get => _variables[variableName]; set => _variables[variableName] = value; } + + /// + public bool TryGetVariable(string name, out IVariable value) + { + return _variables.TryGetValue(name, out value); + } } } \ No newline at end of file