Question: I have a very generic extension method to show any type of list within a console:

```
public static void ShowList<T>(this IEnumerable<T> Values)
{
    foreach (T item in Values)
    {
        Console.WriteLine(item);
    }
}

```

Not when I have a `string` I can use this Method 

```
string text = "test";
text.ShowList();

```

But in case of `string` it doesn't make sense in my application. 

How can I exclude `string` from this method? I've read something about 

```
ShowList<T>(this IEnumerable<T> Values): Where != string //doesn't work

```

Answer: 
You can create another overload of `ShowList()` that is specific for `string` and mark it as `[Obsolete]`:

```
[Obsolete("Not intended for strings", true)]
public static void ShowList(this string val)
{
}

```

By passing `true` to the `IsError` parameter, the compiler will prevent you from using the method.

See [ObsoleteAttribute](https://msdn.microsoft.com/en-us/library/system.obsoleteattribute(v=vs.110).aspx)
For silent ignore you could use this:

```
public static void ShowList<T>(this IEnumerable<T> Values)
{
    if (Values is String) return;
    // ...
}

```

Or if you want to also write the string:

```
public static void ShowList<T>(this IEnumerable<T> Values)
{
    if (Values is String)
        Console.WriteLine(Values);
    else
        foreach (T item in Values)
        {
            Console.WriteLine(item);
        }
}

```