.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Difference between static and dynamic?

Posted By :Narayanan     Posted Date :April 10, 2013    Points :40   Category :.NET Framework 
Static : we can mention how many things we need.
Dynamic : we cannot mention it generates depends upon the requirements.

You can also find related Interview Question to Difference between static and dynamic?  below: 

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention. (More...)

What is the difference between "dynamic SQL" and "stored procedure" ?

Dynamic sql is the bunch of statements that dynamically constructed at run time and not stored in database.
Where as Stored procedures are stored in data base in complied form. (More...)

What is dynamic binding ? How is it different from static binding?

With dynamic binding, the decision on which object method to call is made at runtime.Dynamic binding is polymorphism. with static binding, the decision to on which method to call is made at compile time.c# uses static binding as the default method dispatching mechanism. (More...)

What is difference between lock vs static locks?

static lock is applicable to static methods and variables.

What is the difference between var and dynamic types in C# 4.0?

var gets processed in the compile time itself and shows any error during compile time itself.

dynamic gets processed in the runtime only and in case of errors it is hidden until runtime.

dynamic was introduced as part of the DLR (Dynamic Language Runtime) in .Net.

dynamic d = new MyClass();

Eventhough the method "InexistingMethod" is not there - it will get compiled and thrown exception in runtime.


What is difference between constants, readonly and, static ?

Constants: The value can't be changed
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.


What is static linking and dynamic linking library

Dynamic linking includes only the information needed at runtime to locate the code for a DLL function but in static linking , the linker gets all of the referenced function from a static library and places into your code. (More...)

Difference between Var vs Dynamic?

Var word was introduced with C#3.5(specifically for LINQ) while dynamic is introduced in C#4.0.
Variables declared with var keyword will get compiled and you can have all its related methods by intellisense while variables declared with dynamic keyword will never get compiled. All the exceptions related to dynamic type variables can only be caught at runtime. (More...)

Difference between Static vs Constant

Static Variable:
1.Variable set at run time
2.Can be assigned for reference types.
3.Initialized on constructors
1.Variable set at compile time itself.
2.Assigned for value types only
3.must be initialized at declaration time
4.only primitive data types. (More...)

difference between Var and Dynamic keyword in c#

The Var(Implicit typed local variable) keyword is used to define local variables.In case of Var , the underlying data type is determined at compile time itself based on the initial assignment.Once the initial assignment has been made with Var type , then it will become strongly typed.If you try to store any incompatible value with the Var type it will result in compile time error.

But in Dynamic type, the underlying type is determined only at run time.Dynamic data type is not checked at compile time and also it is not strongly typed.We can assign any initial value for dynamic type and then it can be reassigned to any new value during its life time.

dynamic test="Senthil";
Console.Writeline(test.GetType()) // System.String

Console.Writeline(test.GetType()) // System.Int32

test=new List();
Console.Writeline(test.GetType()) //System.Collections.Generic.List'1[System.String]

It doesn't provide IntelliSense support also.It doesn't give better support when we give work with linq also.Because it doesn't support lambda expressions ,extension methods and anonymous methods.

Check this blog for more info about var and dynamic:-

senthilvijayalakshmi.blogspot.in/2013/03/difference-between-var-and-dynamic.html (More...)

What is the difference between static and instance methods

A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members.

A method declared without a static modifier is an instance method. An instance method operates on a specific instance and can access both static and instance members. The instance on which an instance method was invoked can be explicitly accessed as this. It is an error to refer to this in a static method.

Difference Between Delete and Truncate

.Delete table is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow.

. Truncate table also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster. Of course, truncate table cannot be rolled back.

. Truncate table is functionally identical to delete statement with no "where clause" both remove all rows in the table. But truncate table is faster and uses fewer system and transaction log resources than delete.

. Truncate table removes all rows from a table, but the table structure and its columns, constraints, indexes etc., remains as it is.

. In truncate table the counter used by an identity column for new rows is reset to the seed for the column.

. If you want to retain the identity counter, use delete statement instead.

. If you want to remove table definition and its data, use the drop table statement.

. You cannot use truncate table on a table referenced by a foreign key constraint; instead, use delete statement without a where clause. Because truncate table is not logged, it cannot activate a trigger.

. Truncate table may not be used on tables participating in an indexed view. (More...)

Difference between assembly manifest & metadata?

assembly manifest - An integral part of every assembly that renders the assembly self-describing. The assembly manifest contains the assembly's metadata. The manifest establishes the assembly identity, specifies the files that make up the assembly implementation, specifies the types and resources that make up the assembly, itemizes the compile-time dependencies on other assemblies, and specifies the set of permissions required for the assembly to run properly. This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.

metadata - Information that describes every element managed by the common language runtime: an assembly, loadable file, type, method, and so on. This can include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime. (More...)

What is the difference between ref & out parameters?

An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend