APIs & Integrations

emrehoser
Participant

CS0019 error in HubSpot.Net.Examples

SOLVE

I have clone and tried to run HubSpot.Net.Examples, but there is an error that I cannot solve in HubSpotBaseClient.js file. What is the problem?

 

hub.PNG

 

Severity Code Description Project File Line Suppression State
Error CS0019 Operator '!=' cannot be applied to operands of type 'K' and 'default' HubSpot.NET (net461), HubSpot.NET (netstandard2.0) C:\Users\dke10004\Desktop\HubSpot.NET-master\HubSpot.NET-master\HubSpot.NET\Core\HubSpotBaseClient.cs 114 Active

 

Severity Code Description Project File Line Suppression State
Error CS0019 Operator '!=' cannot be applied to operands of type 'T' and 'default' HubSpot.NET (net461), HubSpot.NET (netstandard2.0) C:\Users\dke10004\Desktop\HubSpot.NET-master\HubSpot.NET-master\HubSpot.NET\Core\HubSpotBaseClient.cs 139 Active

0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

CS0019 error in HubSpot.Net.Examples

SOLVE

Hey @emrehoser,

 

Digging further into this, I found this stackoverflow discussion: https://stackoverflow.com/questions/8982645/how-to-solve-operator-cannot-be-applied-to-operands-of-t..., it state the following:

 

"T is a type argument and can be a class or a struct, Thus compiler won't let you perform actions that doesn't exist in classes and structs.

structs don't have the == and != by default(but can be added), this is why the compiler complains.

If you use the where keyword to add a constraint to the type argument, the Compiler will let you use that type\interface method\operators

constrain T to be a class"

 

As such, could you try something like this:

!entity.Equals(default) --> Reference here: CS0019: Operator '!=' cannot be applied to operands of type 'TEnum' and 'TEnum' where TEnum: Enum · ...

View solution in original post

2 Replies 2
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

CS0019 error in HubSpot.Net.Examples

SOLVE

Hey @emrehoser,

 

Digging further into this, I found this stackoverflow discussion: https://stackoverflow.com/questions/8982645/how-to-solve-operator-cannot-be-applied-to-operands-of-t..., it state the following:

 

"T is a type argument and can be a class or a struct, Thus compiler won't let you perform actions that doesn't exist in classes and structs.

structs don't have the == and != by default(but can be added), this is why the compiler complains.

If you use the where keyword to add a constraint to the type argument, the Compiler will let you use that type\interface method\operators

constrain T to be a class"

 

As such, could you try something like this:

!entity.Equals(default) --> Reference here: CS0019: Operator '!=' cannot be applied to operands of type 'TEnum' and 'TEnum' where TEnum: Enum · ...

emrehoser
Participant

CS0019 error in HubSpot.Net.Examples

SOLVE

Thank you so much.

0 Upvotes