There is no practical difference in this example. Unfortunately, so many sites use this - even a language reference .
The main reason you would use the x is var y pattern is the x is var y variable if you need a temporary variable inside a boolean expression. For instance:
allLists.Where(list => list.Count() is var count && count >= min && count <= max)
By creating the temporary variable count we can use it several times without sacrificing performance when calling Count() every time.
In this example, we could use is int count instead - var is just a stylistic choice. However, there are two cases where var is required: for anonymous types or if you want to allow null values. The latter because null does not match any type.
In particular, for if , however, you can do the same: if (list.Count() is var count && count >= min && count <= max) . But this is clearly stupid. The general consensus seems to be that it makes no sense to use it in if . But language does not bother you, because the prohibition of this particular form of expression in this particular expression of expression will complicate the language.
source share