Wednesday, April 4, 2018

EC Info System

OOPS
1. Diff between struct and class.

2. When we should use struct and when class?
Ans:Its identity is important. Structures get copied implicitly when being passed by value into a method.
It will have a large memory footprint.
Its fields need initializers.
You need to inherit from a base class.
You need polymorphic behavior;
Use a structure if:

It will act like a primitive type (int, long, byte, etc.).
It must have a small memory footprint.
You are calling a P/Invoke method that requires a structure to be passed in by value.
You need to reduce the impact of garbage collection on application performance.
Its fields need to be initialized only to their default values. This value would be zero for numeric types, false for Boolean types, and null for reference types.
Note that in C# 6.0 structs can have a default constructor that can be used to initialize the struct’s fields to nondefault values.
You do not need to inherit from a base class (other than ValueType, from which all structs inherit).
You do not need polymorphic behavior

3. A class has a list struct array, what will be the impact on performance.
Ans : degrade because member variable will go in heap

4. When static variable initialized?
Ans : Static variables are initialized as soon as the class loads with the default value. A variable in C# can never have an uninitialized value.

SQL
1. What is index?
2. Why do we need index?
3. On which column we should apply index.
4. Diff bet store procedure and function.
5. Which function return more than one value?
Ans :

To return multiple values from a function you need to return table

CREATE FUNCTION MyFunction
(
@MyParam int
)
RETURNS TABLE 
(
MyColumn1 int,
    MyColumn2 nvarchar(max)
)
AS
BEGIN


RETURN (SELECT Column1,Column2 FROM MyTable WHERE ColumnX="MyParam)

END

It is called table valued function.

6. Inner join, Left Outer Join, Right Outer Join, Full Join, Cross Join, Union  and Union All
7. If table has wrong entry for a column named gender, write query to correct. Female has entered M and Male has entered F by mistake.
Ans : UPDATE tbl SET Gender = (CASE WHEN Gender = 'Male' THEN 'Female' ELSE 'Male' END)

8. What is data integrity?
9.

Entityframework
1. What is DBContext?
Ans: It is a bridge between your domain or entity classes and the database.

2. We have two table Customer and Order, We want data for the order, customer wise.
3. What is benefit of MVC?
4. What is difference between MVVM and MVC?
5. Which approach will you use model first, code first, data base first.
And which approach will you use when.
6. What is data anotation?
7. Write an annotation so that a field only accept value in hexa decimal.
8. What are contents in edmx file?

http://tutorial.techaltum.com/Edmx-file-in-Entity-Framework.html

WCF
1. How many contract are there in WCF?
2. If we have private property in a data contract than this property will expose or not.
Ans Yes

3. If want to prevent a property from exposing to outside world in WCF.
Ans : Make it private and remove DataMember

4. If we have two method with same name in WCF. Than how will you handle it.
Ans : Overload with Name attribute of OperationContract.

Web API
1. Diff Between Web API and Web Service.
2. We have an enum which contains color name, How will you pass enum value in Web APi method.
Ans: 
Use it like this.
public class Person { public string FirstName { get; set; } public string LastName { get; set; } [JsonConverter(typeof(StringEnumConverter))] public Language PrimaryLanguage { get; set; } }
https://exceptionnotfound.net/serializing-enumerations-in-asp-net-web-api/

1 comment:

aditya55 said...

great information
here tutorial welookups
and javacodegeeks

Followers

Link