You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
736 B
31 lines
736 B
using System.Linq;
|
|
|
|
namespace System;
|
|
public static class StringArrayArgsExtensions
|
|
{
|
|
public static string GetStringPrarm(this string[] args, string key)
|
|
{
|
|
if (!args.Any())
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return args
|
|
.Where(arg => arg.StartsWith(key))
|
|
.Select(arg => arg.Substring(key.Length))
|
|
.FirstOrDefault();
|
|
}
|
|
|
|
public static string GetInt32Prarm(this string[] args, string key)
|
|
{
|
|
if (!args.Any())
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return args
|
|
.Where(arg => arg.StartsWith(key))
|
|
.Select(arg => arg.Substring(key.Length))
|
|
.FirstOrDefault(arg => int.TryParse(arg, out _));
|
|
}
|
|
}
|
|
|