Dynamic- It’s a keyword introduces with the .Net 4.0 and used to keep the data similar to the var keyword. The type of Dynamic type can be changed even at run time. So if we define like: dynamic myVar = new String[] {"hello", "world!!"} ; Then the myVar is of type string array. Now if we do like: dynamic myVar = "Hello" ; Now the myVar type will be used as string type. So we can change the type in case of dynamic. The difference between the var and dynamic is that the dynamic variable uses the same memory location to store the object and not changes throughout the application. 25. Difference between Functions and methods. A. In.Net terminology, both function and method are same. In general, we use method in server side code of .Net but in scripting language we use function like JavaScript function. Here the difference can be function always returns a value whereas method may or may not. It depends upon the retur type of the method. 26. Difference between Abstract classes and Interface. Explain with scenario where to implement one? A. Abstract Class: Collection of the Abstract (Incomplete) and Concrete (complete) members is called as the Abstract class. If there is at least one abstract member in a class, the class must be declared as abstract class. When there is the similar behavior, we can use the abstract class. e.g. We want to calculate the area of few shapes. As this is not generic to the application. We have few shapes - like Circle, Ellipse, Parabola, Hyperbola, Triangle etc. So we can create an abstract class and implement it like below: public abstract class MyAbstractClass { // some other concrete members public abstract void Area();// abstract method } Now in the child class, let’s say i have a circle class and want to calculate the area of the circle: public class Circle: MyAbstractClass { } In the similar fashion, we can calculate the area of other shapes. Interface: Collection of abstract members is called as the Interface. When the behavior is not similar, we need to use t interface. All the members of the interface must be overridden in the child classes. e.g. Print functionality of the application can have an interface method like: interface Inf { void Print(); } Now as this is the generic functionality and can be implemented in any of the class so we have taken it as interface. W can implement this functionality into any page like: class MyClass: System.Web.UI.Page, Inf { public void Print() { // implement details about the Print method } // Here we can implement any kind of print-like print to excel, xml, word all depends on the our decision. } 27. Different forms of Polymorphism. Differences between Abstraction and Polymorphism. A. Polymorphism is to use the same function in many forms. The polymorphism is of 2 types- a. Classical polymorphism (Overloading) b. AdHoc polymorphism (Overriding) Polymorphism = Poly(many) + Morphism(Forms) 9. Overloading: When the runtime (CLR) find the behavior of class members at the compilation of the program, it is called the Classical polymorphism or Overloading. In this, the method name is same but prototypes (method + parameters) are different and it is implemented in the same class. 10. e.g. public class MyClass { public int Add(int a, int b, int c) { return a+b+c; } } Overriding: When the runtime (CLR) find the behavior of class members at the runtime of the program, it is called as th AdHoc polymorphism or Overriding. In this, the method name as well as the prototype (method + parameters) is same b they are implemented in the different class. We use virtual keyword in the base class method to override in the child cla using the override keyword. e.g. public class MyBaseClass { public virtual void Show(string message) { Console.WriteLine(“Your message is : â€+ message); } } public class MyChildClass: MyBaseClass { public override void Show(string message) { Console.WriteLine(“Your new message is : â€+ message); } } 11. Abstraction is the behavior to get the required functionality. To implement the abstraction, we use access specifiers where if we declare the members as private, it means they will be available only to the current class and if we make the as public, the other classes can also use them. So Abstraction is used to show only the essential features It is also use to hide the unnecessary data which is not relevant but present. 12. Abstract keyword is also used to get the abstraction behavior. We can use Abstract Class and Interface to implement Abstraction. 28. What are Delegates and Events? · Delegate works like a function pointer in C language. · Delegate holds the address of the function. · Delegate hides the actual information which is written inside the method definition. · A delegate can hold address of a single function as well as the address of multiple functions. · There are 2 types of delegate- - Single cast delegate (hold single function) and - Multicast delegate(hold multiple functions). · Addition and subtraction are allowed for the delegates but NOT multiplication and division. It means, we can a delegates, subtract delegates etc. e.g. To create a single cast delegate, first we can create a class with a method as: public class DelegateDemo { public void Show(string msg) { Console.WriteLine(msg); } } Now we can call the method Show using the delegate as: public delegate void MyDelegate(string message); //declare delegate now we need to create the object of the delegate with the address of the method as: DelegateDemo obj = new DelegateDemo();//class object MyDelegate md= new MyDelegate(obj.Show(“Hello World!!â€)); md(); // call the delegate We can create the events and event handler by using delegate with the below syntax: public delegate void textChangedEventHandler(Object sender, TextEventArgs e); This event handler will be used to handle the textbox textchanged event. More details about the delegate and events can be found at the below link: Covariance and Contra-variance. ://blogs.msdn.com/b/csharpfaq/archive/2010/02/16/covariance-and-contravariance-faq.aspx What are Extension methods? xtension methods are special types of methods which are static methods but called as the instance methods. The extensi hods are added with the .Net framework 3.5 and with the Visual Studio 2008. se methods won’t affect the existing class and the label. These methods are used for the extra behavior which the call provide. There is no need to build the class again if we add any extension method to the class. re are various inbuilt methods added in .Net 3.5 with the introduction of LINQ. We can see the extension methods like Orde hen we use the Linq as: ] numbers = { 10, 45, 15, 39, 21, 26 }; orderedNumbers = numbers.OrderBy(a => a); What are Anonymous methods and Lambda Expression? Anonymous methods are those methods which does not have the name. As they don’t have the name, so there is no w all these methods. These methods are created by using the delegate as below: ton1.Click += delegate{listBox1.Items.Add(textBox1.Text)}; bda Expression: It’s an easy way to create anonymous functions. It is also an anonymous function which has the ability to contain expressions and statements. We can create the delegate and expression tree types using the lambda ression. more details regarding the anonymous method and lambda expression, we can go through the below link: ://www.codeproject.com/Articles/47887/C-Delegates-Anonymous-Methods-and-Lambda-Expression Multithreading. How to implement Multithreading? xecuting more than one processes simultaneously is called as multithreading. To implement the multithreading concept, we d to use the System. Threading .dll assembly and the System. Threading namespace. write the thread program, we need to create a class with the method. Now we can create the thread object and then pass method by using the class object to the method. r that we need to create the ThreadStart delegate which will call the actual method of the class. can go through below link for more explanation and other details regarding the implementation and the code snippet: ://www.codeproject.com/Articles/1083/Multithreaded-Programming-Using-C heck the below interfaces which are used in these scenarios: onvert Boolean values to Visibility values? ompare two integer values?- IComparable interface ompare String values? IComparer interface
Server
What is the difference between a View and a Cursor? iew: It is one of the database object which is also called as virtual table. We can also say that it is a window through wh can see some part of database. View is also called as stored query because we are going to fetch data using View. does not contain any data. It’s just a virtual table which is used to get the records from the base table for which the is created. View is faster than ad hoc queries because when we create the view and execute it once. Next time onwards be available as the compiled format. So whenever the view is called, it will just execute rather than compiling. sor: Cursor is a database object which is also the buffer area and created as a result of any sql statement to hold the rmediate values. sor is used to format the rows individually. By using the cursor, we can process the individual rows. There are 4 types of ors in Sql Server- tatic Cursor ynamic Cursor ey set cursor ead-only cursor How to execute multiple update on different conditions in a single query? o execute multiple update using a single Sql update statement is the new feature available with the SQL Server 2008. In , we can update multiple rows using a single update command. Left outer joins and Right Outer joins oins are used to retrieve data from more than 1 tables using some conditions. There are 3 types of outer joins in SQL Serve abase- eft Outer Join ight Outer Join ull Join syntax for right outer join condition is: Col1 = *T2.Col1 rder to extract the matched rows from both the tables and unmatched rows from the first table and then unmatched row the second table, full join is used. The syntax for full join condition is: Col1* = *T2.Col1 Exception handling. xception Handling is the way to handle the unexpected error at runtime of the application. From the SQL Server 2005 ion, try…catch block is also supported to catch the exceptions in SQL Server database. There is various other ways to ch the error like using Global temporary variables @@Error, inbuilt method RaiseError etc. What is Performance Tuning? How do you implement it. erformance Tuning is the process through which we can optimize the SQL Server objects like functions, triggers, stored edure to achieve high response time to the front end applications. In the performance tuning process we generally check f below point and optimize the objects processing: Through Query Execution plan, check for the processing time of the query execution. heck the join conditions and break all the condition for executions of the queries individually. heck for the error prone process, conditions in the queries. heck for the loops whether they are terminated if any error occurs. heck for the processes which are taking more time in execution and how to reduce the response time. Difference between Having and Where clauses. When the 'where' clause is not able to evaluate the condition which consists of group functions, Having clause is used. ing clause is always followed by the Group By clause. ere' clause is used to filter the records based on the conditions. If there is the requirement to get the group data in the ct statement and where clause is not able to get it, we can use the Having clause. Display DeptNo, No.of Employees in the department for all the departments where more than 3 employees are working
ECT DEPTNO, COUNT(*) AS TOTAL_EMPLOYEE M EMP UP BY DEPTNO HAVING COUNT(*) >3
Difference between Temp tables and Tables variables? e can’t join the temp tables as they don’t allow the foreign key constraints. emp tables are created in TempDB database. e can use the same temp table name for the different user sessions. ostly used in stored procedure to handle the intermediate data. What does @ and @@ suffixed by property names specify? - This is used for the variable declaration @name varchar2(50) - This is used for the Global variable declaration @@Error=0 Self-join queries. elf-Join is a type of join which is used to join the same table by creating the multiple instances of the same table. So we c 2 instances of the same table in case of self-join. This type of join is used when there is the requirement to get the renced data which is available in the same table. A table contains EmpId, Ename and ManagerId he manager is also an employee. Now if we want that who is the manager of which employee. In this situation, we need to te the instance of the same table and get the required data as:
ECT EMPID, ENAME, ENAME AS [MANAGER NAME] M EMP E1, EMP E2 ERE E1.EMPID= E2.MANAGERID
Types of Index. Index is one of the database objects which is used to improve the performance of the database queries. It reduces the tab n while retrieving the data from the database and the search gets fast- re are 2 types of indexes used in the SQL server: lustered index on clustered index re are 3 more types of index but those comes under the above two- nique index omposite Index ML Index-added in SQL Server 2005 rimary Key- It is a key to make the unique identification of the row in a table. It doesn't allow null values in the primary k mn. We can create the lookup columns based on the primary key. One table allows maximum of 1 primary key and in 1 table can create the primary key column by using 16 columns. Due to one of the normalization rule, we have to create primary ke the table to make the rows unique. que Key:- (Primary Key + Not null) is called as unique key. Unique key is also used to make the rows as unique in a table. only difference between primary key and unique key is that primary key does not allow null value while the unique key allow limitation of the null in unique key is that it allows only one Null value. So only in one row, we can make the key as null for unique key. didate key- The key other than primary key, to make the rows as unique is called as candidate key. In candidate key, we the columns which are not in the primary key and make the key for uniqueness of the row. What is the default value for Datetime. What are Min and Max values for Date in 2008. The default value of Date is CURRENT_TIMESTAMP w are the new date and time values in Sql Server 2008: QL Server 2008: ateTime2 Value: 0001-01-01 00:00:00.0000000 Value: 9999-12-31 23:59:59.9999999 ate Value: 0001-01-01 Value: 9999-12-31
F
What is WCF also known as? WCF (Windows Communication Foundation) is also know as Indigo by its code name. Difference between WCF and Web Services? elow are the main differences between the WCF and Web Service: b Service: an be hosted in IIS only nly two types of operations affects- One-Way, Request-Response an be hosted in IIS, Self Hosting, WAS, Windows Services etc hree types of operations affects- One-Way, Request-Response and Duplex o serialize the data use System.Runtimel.Serialization o encode the data use- XML 1.0, MTOM,Binary, Custom CF Service can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P etc. What are Endpoints? he collection of Address, Binding and Contract is called as End Point. In Sort, Point = A+B+C ress (Where)- It means where the service is hosted. URL of the service shows the address. ing (How)- How to connect to the service, is defined by the Binding. It basically has the definition of the communication nnel to communicate to the WCF service tract (what)- It means what the service contains for the client. What all the methods are implemented in the WCF service lemented in the Contract. What are Behavior and Bindings? inding mainly describes about the communication of the client and service. For this, there are protocols corresponding to t ing behavior which will take care of the communication channel. There are different protocols which we use for the differen es of bindings. E.g. HTTP, TCP, MSMQ, Named Pipes etc. avior is used for the common configurations that could be for endpoints. When we use the common behavior, they affect to he end points. Adding the service behavior affect the service related stuff while the endpoint related behavior affects the points. Also operations level behavior affects the operations. What are different types of Contracts supported? here are mainly 5 type of contracts used in WCF service: ervice Contract peration Contract ata Contract essage Contract ault Contract What is the difference between Transport and Message Security mode? the service, the speed is faster as direct message is going to the client from the service. sage level security- This type of security in WCF is used where we don't have the fixed transport medium and we need t ure each message which is floating between the server and the client. In this type of security we use certain algorithms fo ing the message as secure message. We use some extra bits and send with the message. We also use some encryption hniques like SHA1 or MD5 which make the proper security for our message. As each message needs to be secured, this type ecurity makes some delay in the process of sending and receiving the messages. How to configure WCF security to support Windows authentication? o support the WCF security in Windows Authentication, we need to add the ClientCredetialType attribute to “Windowsâ er the security tab element: sport clientCredentialType="Windows" How to use Fault Contract? Fault Contract is mainly used for viewing and displaying the errors which occurred in the service. So it basically documents error and the error message can be shown to the user in the understandable way. We can’t use here the try….catch k for the error handling because the try…catch is the technology specific (.Net Technology). If we use the try...catch k for handling the errors, the error will not be reached to the client who is consuming the service. Because this error will no ncluded in the message. So we use the Fault contract for the error handling. To use the Fault contract, we can simply write like the below: lic int Add(int number1,int number2) write some implementation ow new FaultException (“Error while adding data..â€); e the fault Exception method is the inbuilt method which will throw the exception and display the message . We can use the tom class so that the message can be customized and the customized message can be sent to the client. we can create a clss like: lic Class CustomException lic int ID {get;set;} lic string Message {get;set;} lic string Type{get;set;} erationContract]
ultContract(typeOf(CustomException))]
Add(int num1,int num2); while implementation of the Add method, we can assign the class properties.
ist out the differences between Array and ArrayList in C#?
Array stores the values or elements of same data type but arraylist stores values of different datatypes. Arrays will use the fixed length but arraylist does not uses fixed length like array.
· 9) Why to use “using†in C#?
· “Using†statement calls – “dispose†method internally, whenever any exception occurred in any method call and in â €œUsing†statement objects are read only and cannot be reassignable or modifiable.
What is the difference between “constant†and “readonly†variables in C#?
“Const†keyword is used for making an entity constant. We cannot modify the value later in the code. Value assigning is mandator to constant variables. “readonly†variable value can be changed during runtime and value to readonly variables can be assigned in the constructor or at t time of declaration.
Explain “static†keyword in C#?
Static†keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made c. If the variable is made static then it will have a single instance and the value change is updated in this instance.
What is the difference between “dispose†and “finalize†variables in C#?
be called from the code.
What is the difference between “finalize†and “finally†methods in C#?
Finalize – This method is used for garbage collection. So before destroying an object this method is called as part of clean up activity Finally – This method is used for executing the code irrespective of exception occurred or not.
· 20) Can we have only “try†block without “catch†block in C#?
· Yes we can have only try block without catch block.
· 22) Do we get error while executing “finally†block in C#?
· Yes. We may get error in finally block.
What are the differences between static, public and void in C#?
Static classes/methods/variables are accessible throughout the application without creating instance. Compiler will store the method address as an entry point. Public methods or variables are accessible throughout the application. Void is used for the methods to indicate it will not return any value.
· 25) What is the difference between “out†and “ref†parameters in C#?
· “out†parameter can be passed to a method and it need not be initialized where as “ref†parameter has to be initialized befo it is used.
· 26) Explain Jagged Arrays in C#?
· If the elements of an array is an array then it’s called as jagged array. The elements can be of different sizes and dimensions.
What are reference types in C#?
w are the list of reference types in C# - interface object
· 33) What you mean by inner exception in C#?
· Inner exception is a property of exception class which will give you a brief insight of the exception i.e, parent exception and child exception details.
What is the difference between “StringBuilder†and “String†in C#?
StringBuilder is mutable, which means once object for stringbuilder is created, it later be modified either using Append, Remove or Replace. String is immutable and it means we cannot modify the string object and will always create new object in memory of string type.
· 40) Explain Generics in C#?
· Generics in c# is used to make the code reusable and which intern decreases the code redundancy and increases the performance an type safety. Namespace – “System.Collections.Generic†is available in C# and this should be used over “System.Collections†types.
· 41) Explain object pool in C#?
· Object pool is used to track the objects which are being used in the code. So object pool reduces the object creation overhead.
What you mean by delegate in C#?
gates are type safe pointers unlike function pointers as in C++. Delegate is used to represent the reference of the methods of some return and parameters.
What are the types of delegates in C#?
w are the uses of delegates in C# - Single Delegate
What are the three types of Generic delegates in C#?
w are the three types of generic delegates in C# - Func Action Predicate
What are the differences between events and delegates in C#?
n difference between event and delegate is event will provide one more of encapsulation over delegates. So when you are using events ination will listen to it but delegates are naked, which works in subscriber/destination model.
What are the uses of delegates in C#?
w are the list of uses of delegates in C# - Callback Mechanism Asynchronous Processing Abstract and Encapsulate method Multicasting
· 49) Why to use “Nullable Coalescing Operator†(??) in C#?
· Nullable Coalescing Operator can be used with reference types and nullable value types. So if the first operand of the expression is n then the value of second operand is assigned to the variable. For example,
· double? myFirstno = null; double mySecno; mySecno = myFirstno ?? 10.11;
What is the difference between “as†and “is†operators in C#?
Define Multicast Delegate in C#? elegate with multiple handlers are called as multicast delegate. The example to demonstrate the same is given below
lic delegate void CalculateMyNumbers(int x, int y); x = 6; y = 7; culateMyNumbers addMyNumbers = new CalculateMyNumbers(FuncForAddingNumbers); culateMyNumbers multiplyMyNumbers = new CalculateMyNumbers(FuncForMultiplyingNumbers); culateMyNumbers multiCast = (CalculateMyNumbers)Delegate.Combine (addMyNumbers, multiplyMyNumbers); tiCast.Invoke(a,b);
What is the difference between CType and Directcast in C#?
CType is used for conversion between type and the expression. Directcast is used for converting the object type which requires run time type to be the same as specified type.
Is C# code is unmanaged or managed code?
code is managed code because the compiler – CLR will compile the code to Intermediate Language.
Why to use lock statement in C#?
k will make sure one thread will not intercept the other thread which is running the part of code. So lock statement will make the thread , block till the object is being released.
Explain Hashtable in C#?
used to store the key/value pairs based on hash code of the key. Key will be used to access the element in the collection. For example, htable myHashtbl = new Hashtable(); ashtbl.Add("1", "TestValue1");
myHashtbl.ContainsKey("1");
What is enum in C#?
keyword is used for declaring an enumeration, which consists of named constants and it is called as enumerator lists. Enums are value s in C# and these can’t be inherited. Below is the sample code of using Enums
enum Fruits { Apple, Orange, Banana, WaterMelon};
Which are the loop types available in C#?
w are the loop types in C# - ile While
What is the difference between “continue†and “break†statements in C#?
“continue†statement is used to pass the control to next iteration. This statement can be used with – “whileâ€, “forâ€, â €œforeach†loops. “break†statement is used to exit the loop.
What are the collection types can be used in C#?
w are the collection types in C# - ArrayList Stack HashTable Bit Array
Explain Attributes in C#?
Attributes are used to convey the info for runtime about the behavior of elements like – “methodsâ€, “classesâ€, “enums†etc. Attributes can be used to add metadata like – comments, classes, compiler instruction etc.
List out the pre defined attributes in C#?
w are the predefined attributes in C# - Conditional Obsolete Attribute Usage
What is Thread in C#?
ad is an execution path of a program. Thread is used to define the different or unique flow of control. If our application involves some tim suming processes then it’s better to use Multithreading. which involves multiple threads.
List out the states of a thread in C#?
w are the states of thread – Unstarted State Ready State
· 79) Explain Static Members in C# ?
· If an attribute's value had to be same across all the instances of the same class, the static keyword is used. For example, if the Minim salary should be set for all employees in the employee class, use the following code.
· private static double MinSalary = 30000;
· To access a private or public attribute or method in a class, at first an object of the class should be created. Then by using the object instance of that class, attributes or methods can be accessed. To access a static variable, we don't want to create an instance of the class containing the static variable. We can directly refer that static variable as shown below.
· double var = Employee.MinSalary ;
p tables are available ONLY to the session that created it and are dropped when the session is closed. ##temp tables (global) available to ALL sessions, but are still dropped when the session that created it is closed and all other references to them are ed. hat are Windows services? dows services, previously known as NT services, are applications that are installed on the system as system services. In other ds, Windows services are applications that run in the background with the Windows operating system. The primary use of dows services is to reduce the consumption of memory required for performing backend operations. Let's take an example to erstand this easily. Suppose you want to perform a variety of functions, such as monitor the performance of your computer or lication, check the status of an application, and manage various devices, such as printers. uch a case, you can use Windows services to reduce memory consumption. In addition, Windows services can run on your tem even if you have not logged on to your computer. In addition, these services do not have any user interface.