Dotnet interview questions for experienced-Part1
C# language is now used in most of the big organizations. whoever worked as C# developer or dotnet developer. Here are some interview questions for you people. please go through if any thing need to be included feel free to comment.
1. Difference between table variable and temp table in SQL server?
Temporary tables are physical tables created in tempdb and it acts like a real table and it's scope is only session window. You can create constraints to temp tables.
Script to create temp table.
Create table #temp1(
--some columns with datatypes.
)
on other hand table variables acts like variables and scope is for the batch of query execution.
Script to create temp table.
Declare @temp1 table(
--some columns with datatypes.
)
2. Difference between view and partial view?
View will contain full html markup and we can include this in master page or exclude.
on other hand Partial view is chunk of html you can include it anywhere as a chunk this data refresh no need full page refresh.
3. What are main constraints for a table in SQL server?
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT
4. What is the difference between View data and View Bag?
ViewData is dictionary object and View Bag is dynamic property.
ViewData need typecasting and null check. for View Bag typecast not required it is a dynamic type.
5. What is Repository pattern in C# language?
Repository pattern is a way of implementing a data access layer to provide more object oriented approach
6. What a dynamic variable will do in C#?
Dynamic keyword is used to store any type of variable in C#. Type checking for this types will take place in run time.
example: dynamic d="Hello World";
7. Difference between object type variables and dynamic variables?
Only Type Check is different between this 2 variables. for object type variables type check will take place in compile time where as for dynamic variables type check will take in run time.
8. What null-coalescing operator will do?
This will check left side value is null or not. if null then it will take right side value or else the left side value.
Example:
string a= username ?? "";
Now if username comes null then this expression won't throw null exception instead it will take right hand side blank and assign to a .
in C# 8 we have ??= also as null coalescing operator used to replace the code as below with this operator.
if (variable is null)
{
variable = expression;
}
replaced with:
variable ??= expression;
9. What is params keyword do in C#?
By using the params keyword, you can specify a method parameter that takes a variable number of arguments. The parameter type must be a single-dimensional array.
No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.
When you call a method with a params parameter, you can pass in:
A comma-separated list of arguments of the type of the array elements.
An array of arguments of the specified type.
No arguments. If you send no arguments, the length of the params list is zero.
10. Can we pass additional type of parameters in function definition?
No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.
Thanks for reading.
Here are my popular Blogs
Post a Comment
0 Comments