Monday, May 28, 2012

C# Vs VB.net

1. 'Using' keyword of C# is used to release unused resources of an object.
Font myFont = new Font("Times New Roman", 8.0f);
            using (myFont) // not recommended
            {
                // use myFont
            }
After execution of inside statement of the braces resources used by myFont will be released. Class where you use 'Using' must to implement IDisposable interface.

2. C# is case sensitive.
3. Optional parameters to functions is not supported in C#.
4. C# doesn't have 'with' keyword that used to manipulate properties of an object in a single block.
With myObject
.Height = 20
.ForeColor = System.Drawing.Color.Green
.Text = "Hello..."
End With

5. Unstructured error handling not supported in C#. (On Error GOTO) is not supported in C#.
6. There is a concept of function Hiding in c# its called Hiding and in VB.Net its called Shadowing. We can have same name function in derived class that exist in base class that hides existence of that base class function in derived class.  In c# we mark it 'New' and in VB.Net we mark it 'Shadow'. Difference is that in C#, both the functions must have same signature while vb.net allow to change signature function.
7. In VB.Net we can call function by passing parameter with extra bracket that is not support by C#.
Dim y As Integer = 8
Dim z As Integer
z = Add(y) //This will set both Y and Z to 7.
z = Add((y)) //This will set Z to 7 but Value of Y will not be change, as we have included extra parentheses while calling.
             
The Subtract function:
Public Function Subtract(ByRef x As Integer) As Integer
x = x - 1
Return x
End Function

Saturday, May 26, 2012

Value and Reference types

All the types are derived from System.Object base type.

Value type - contain actual value on its memory location. Its allocated to stack.
Reference type - contains a new memory location address on its memory location. Its allocated to heap.
Changing value of a reference type can effect some other objects those are referring that reference type.

Value types ex. - All numeric types, Datetime, Boolean, Char, Structure, Enumeration.
Reference types ex. - String, Array, Delegate, Class.

* Structure and Enumeration are value types even they contain reference type members.
* String, Array are reference types even they contain value types.

Types of JIT compiler

Pre JIT - Compiles whole code in a single cycle.

Econo JIT - Compiles code part by part when required. It means compiles methods those called at runtime, and then remove those compiled code when not required. That means called code compiles, serves and then frees.

Normal JIT - Compiles code part by part as Econo but only once when any code part called first time, then it put that code to cache and if required later, then serves from cache that part.

CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...