This commit is contained in:
CortexCore
2024-06-12 16:01:56 +08:00
parent 01b19130a9
commit 126131b842
8 changed files with 208 additions and 112 deletions

View File

@@ -4,6 +4,23 @@ namespace BITKit
{
public static class MathO
{
public static T As<T>(this object self) where T : class => self as T;
public static T As<T>(this object self) where T : class
{
{
if (typeof(T) == typeof(object[]))
{
var o = new object[1];
o[0] = self;
return o as T;
}
}
{
if (self is object[] { Length: 1 } o)
{
return o[0] as T;
}
}
return self as T;
}
}
}