Click or drag to resize

YArgumentParserTryGetArgument Method

Overload List
  Name Description
Public method Code example TryGetArgument(String) Try to get a YArgument from the argName or null if the given param is not found.
Example
C#
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument("s");
YArgument mainArgument = argumentParser.GetArgument(string.Empty);
YArgument nullArgument = argumentParser.GetArgument("m");
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Public method Code example TryGetArgumentT(T) Try to get a YArgument from the argName or null if the given param is not found.
Example
C#
enum ArumentsTypes
{
    main = 0,
    s,
    m,
    readonly,
}
YArgumentParser argumentParser = new YArgumentParser(new string[]
{ 
    "First value of the main argument",
    "Second value of the main argument",
    "-s",
    "source",
    "/d",
    "destination",
    "-readonly"
});
YArgument argument = argumentParser.GetArgument(ArumentsTypes.s);
YArgument mainArgument = argumentParser.GetArgument(ArumentsTypes.main);
YArgument nullArgument = argumentParser.GetArgument(ArumentsTypes.m);
In results :
  • argument.Values will be { "source" }
  • mainArgument.Values will be { "First value of the main argument", "Second value of the main argument"}
  • nullArgument will be null
Top
See Also