It always surperises me how simple some of these questionare – often I get asked theses:
- What is the difference in Sql Server when deleting all records in a table using delete or trucate.
Simply put if one uses truncate on a table any auto-increament fields in the table are set to the initail value – 0, and the deleted data is lost forever as the deleted rews are not recorderd in the back up log. A trucate will fail if there is any table with a foreign key referencing any row in the table truncated. Applying sql delete each deleted row is recorded in the back up log and can be recovered.
- What is the difference between a struct and class in C#.
An struct is a value type, and once created the instanance of is immutable (its a value type). A struct can not be inherited but can implement an interface.
Relatively simple – now for something that really show ones knowledge
- Now this question is what I like. You have a delegate that accepts an int and returns a integer; The delegate has three functions assigned to its invocation list. The funtions have been assigned inside a simple method which has a local int variable x initialised to the value of 2.
- The functions on the delegates invocation list, in order of assignment are:
- multiply the input value by 2 and return the result
- add 7 to the local x varaible and multiply the input value by 3 returning the input value
- substrct the input value from the local varible x and return the input value multiplied by 2
- The delgate is called with the local variable x what is the result and why ?
The answer is 6.
Why, I’ll explain later but simply put the input value is closed i.e. the delegate acts like a closure.
Now back to Seria A which has been neglected due to work offers and answering techincal questions like 1 & 2.