The following snippet will allow you to use the IsOfType extension method, simple but usefull!
Extension method C#
public static bool IsOfType<T>(this object input) { return input.IsOfType(typeof (T)); } public static bool IsOfType(this object input, Type type) { return (input.GetType() == type); }
Extension method VB.NET
<System.Runtime.CompilerServices.Extension> _ Public Shared Function IsOfType(Of T)(obj As Object) As Boolean Return input.IsOfType(GetType(T)) End Function <System.Runtime.CompilerServices.Extension> _ Public Shared Function IsOfType(input As Object, type As Type) As Boolean Return (input.GetType() = type) End Function
RT @CodeSnippetsNET: IsOfType extension method for .NET http://t.co/3qt9xZmOsg #csharp #vb #dotnet #programming #coding