Files
SystemExtensions/SystemExtensions.NetCore/Extensions/ObjectExtensions.cs
T
2024-10-16 14:09:13 +02:00

19 lines
433 B
C#

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace System.Core.Extensions;
public static class ObjectExtensions
{
public static T ThrowIfNull<T>([NotNull] this T obj, [CallerArgumentExpression("obj")] string? paramName = null)
where T : class
{
if (obj is null)
{
throw new ArgumentNullException(paramName);
}
return obj;
}
}