I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using default(T). When you call default on a value type
I know this question is old, but there has been an update.
Since C# 7.0 you can use the is operator to compare types. You no longer require the usage of typeof as in the accepted answer.
public bool IsObjectString(object obj)
{
return obj is string;
}
https://docs.microsoft.com/en-US/dotnet/csharp/language-reference/keywords/is