sveawebpay / dotnet-integration

SDK for Sveas standalone payment methods
Other
5 stars 14 forks source link

Use Is and As instead of GetType() #5

Closed irkush closed 10 years ago

irkush commented 10 years ago

Creating new objects just to compare types is not effective. ( And also not the C# way of life. )

Better to use:

var specificObject = generalObject as MySpecificObject;
if(specificObject != null)
{
   // Do something awesome with my typesafe object.
}
brolund commented 10 years ago

Or even better, create an abstraction that doesn't need type casting. :-)

Sinsabre commented 10 years ago

Solved in b09f10fbf80d8b0f4db01071e08ea83c72e3c4e0