-
Nullable notes
Nullable is value type object. But the following code can be compiled.
int? x = null
Isn't "null" supposed to be used with reference type, why it can be assigned with value type? It turns out to be just syntax suger, and the compiler emit the following code. It does not call any constructor.
IL_0001: ldloca.s x IL_0003: initobj valuetype [mscorlib]System.Nullable`1<int32>
However, if you write the following code, compiler will emit the msil like the following. It call the constructor.
int? y = 123;
-
make your obsolete method invisible
When I started to use moq, there was lots example of moq that use mock.Setup method, althought these code can be compile. The this method is not shown up in intellisense popup, it turns out in the latest version of moq, it hide this memeber like below.
[EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Expect has been renamed to Setup.", false)] public ISetup<T> Expect(Expression<Action<T>> expression); -
When a constructor is not called
Normally, when we build a .net object, clr will call the constructor.
But In a few situations, an instance of a type can be created without an instance constructor being called. In particular, calling Object's MemberwiseClone method allocates memory, initializes the object's overhead fields, and then copies the source object's bytes to the new object. Also, a constructor is usually not called when deserializing an object.
-
Links in asp.net
There are serveral helper class which help to generate links.
//When you generate link with the same controller Html.ActionLink();
-
ajax header
Most of the javascript library add a header, when it use ajax to make a http quest.
x-requested-with: XMLHttpRequest