It's potentially annoying to have an extension method like that turn up on almost every type. With just a single one, it's probably a minor irritation at most, but in the future you may find yourself coming up with more this object
or this T
extension methods, and either you'll start to get a very clogged up Intellisense. So think about whether this is really something that you want frequently enough to justify it. If you're working on code that may be maintained by colleagues, check their opinions.
Note also that new[] { source }
actually has fewer characters than source.ToIEnumerable()
. Which is more readable and clear in stating what it is doing is arguable, but at least the array is instantly universally recognisable.
So while it would be harsh to say that it's "bad practice", on balance I would probably advise slightly against it. If the benefits seem to outweigh the costs to you, though, then go for it.
As a side-note, you don't need your where T : new()
condition, either. It's the array that you're creating a new instance of, not the T
itself.