I know from [this question](https://stackoverflow.com/questions/356846/c-var-vs-specific-type-performance) that `var i = 1` and `int i = 1` are exactly the same in IL. The compiler simply replaces `var` with the actual type at compile time. But, are there any instances where `var` could cause problem behavior (maybe the compiler guesses the wrong type?)
['https://Stackoverflow.com/questions/5738073', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/221061/']
I don't believe the compiler will *guess the wrong type.* However, it might *infer a type you didn't intend*, but that's not the same. 

Consider the perfectly legal 

```
decimal foo = 10;
decimal bar = 4; 
decimal baz = foo / bar; 

```

In the code, `baz` will very clearly be 2.5. The integer literals will be converted to decimals prior to being stored and then the math takes place on the decimal values. Remove the explicit typing and the result is different.

```
var foo = 10;
var bar = 4;
var baz = foo / bar;

```

Now everything infers to int and `baz` is 2 because now the math is taking place with integers. 

So, yes, code semantics could theoretically change if you introduce `var` where it was not before. So the key is to understand what type inference is really going to do with your code and if you want something to be a decimal (or any specific type X), declare it in such a way that it will be. For type inference, that would be 

```
var foo = 10m;

```
In addition to the ambiguous:

```
var x = null;

```

the compiler will also not infer the type of overloaded method groups:

```
var m = String.Equals;

```

nor will it infer the type of lambda expressions, which can be either `Func<>` or `Expression<Func<>>`:

```
var l = (int x) => x + 1;

```

All that said, Anthony is right: the compiler will never do the wrong thing, though it might not do what you expect. When in doubt, hover over `var` in VS to see the static type.