Reputation: 13
I'm trying to create an extension method in a dotnet core 2.1 application and it does not compile.
My Extension method:
public static class ObjectExtension
{
public static bool IsNull(this Object object)
{
return Object.ReferenceEquals(object, null);
}
}
Error output:
ObjectExtension.cs(7,47): error CS1001: Identifier expected ObjectExtension.cs(7,47): error CS1003: Syntax error, ',' expected ObjectExtension.cs(7,53): error CS1001: Identifier expected ObjectExtension.cs(9,43): error CS1525: Invalid expression term 'object'
Upvotes: 1
Views: 31
Reputation: 2566
Add @
to object
public static class ObjectExtension
{
public static bool IsNull(this Object @object)
{
return Object.ReferenceEquals(@object, null);
}
}
Upvotes: 0
Reputation: 30565
object
is reserved word and cannot be used. please try to change it and compile again
Upvotes: 1