mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
21 lines
435 B
C#
21 lines
435 B
C#
namespace BetterAmongUs.Helpers;
|
|
|
|
internal static class CastHelper
|
|
{
|
|
internal static bool TryCast<T>(this object obj) => obj is T;
|
|
|
|
internal static bool TryCast<T>(this object obj, out T? item) where T : class
|
|
{
|
|
if (obj != null && obj is T casted)
|
|
{
|
|
item = casted;
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
item = null;
|
|
return false;
|
|
}
|
|
}
|
|
}
|