Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

How to identify that when we open file dialog to notify that we are searching the document

private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { label2.Text = "Document Fetched"; } private void button1_Click(object sender, EventArgs e) { label2.Text = "Searching Document to Read...."; openFileDialog1.ShowDialog(); }

How to identify that the user is typing ?


private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { label1.Text = "Typing........."; }

Below are the list of some new feature expected in asp.net 4.5 (1)New WebSockets Support (2)Improvements in Garbage Collector (3)Support for Windows Runtime (4)Support for Metro Style Applications (5)Async Programming Support (6)Faster ASP.NET Startup (7)Better Data Access Support (8)Workflow Support BCL Support
The difference between innerText and innerHTML is innerText is interpreted as text where as innerHTML is interpreted as HTML. Example: <Div ID="Test"> <b>Test for InnerText and InnerHtml</b><Div>

1. document.getElementById('Test').innerHTML // output: <b>Test for InnerText and InnerHtml</b 2. document.getElementById('Test').innerText // output: Test for InnerText and InnerHtml

1. 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. Example: Var strNameList=new List<string>(); By using this statement we can store list of names in the string format. strNameList.add("Senthil"); strNameList.add("Vignesh"); strNameList.add(45); // This statement will cause the 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. Example: dynamic test="Senthil"; Console.Writeline(test.GetType()) // System.String test=1222; Console.Writeline(test.GetType()) // System.Int32 test=new List<string>(); 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. Static 1. Static member is a reference type. 2.Variable set at run time. 3.Static member can be accessed without creating instance of the class or can be changed from many location.

Const 1.Cost member is a value type. 2.Variable set at compile time. 3.It can't be changed in the application creating instance of the class or can be anywhere else in the code.

An abstract class contains abstract and non abstract method.we can declare it by using keyword abstract. The abstract keyword allows us to create any class and its member , that may be incomplete and must be implemented in a derived. Using abstract class multiple derived classes can share definition of base class. Lets take an example Suppose we are building a house, where we want All room must be same area.. what we will do ? we will make a method ,Suppose it is RoomArea() and implements its body ..here we have forced to architect that All room must be equal in Area therefore we have made method and its definition. Lets take other situation , Now we move to door's color.. This time we left it over architect,he is free to Apply any color of his choice on door.we are not interested in color. what we have done here ,we have bounded to architect that method should be our choice, so i am giving you its body but i am not interested in door's color so you can implement it in your way. abstract class House { public void RoomArea() { // body ...All room must be equal in area // it is normal method } abstract public void DoorColor(); // Abstract method }

Few important points about abstract class 1. We can not use abstract class without inheriting it. 2. Only abstract members are possible in abstract class. 3. Abstract class can have constructor. 4. We Can not create direct object of abstract class. 5. Any Class derived fro an abstract class must implement all the abstract members of the class by using the override keyword unless the derived class itself abstract.
Abstract methods are declared in Abstract Class. All abstract method have to compulsory Implemented in the subclass(Abstract derived class). But other methods in Abstract class, except abstract method, not compulsory to Implement its derived class. In Interface all methods are abstract method(So no need to declare abstract method).

ViewState: We can hold the values in the viewstate and we can retrieve it wherever it is needed within a page. The value will be saved on the client side. Session : We can hold the values in the session and we can retrieve it back wherever it is needed in an application The value will be saved on the server side. viewstate:client side state mechanism purpose to retain values for specific page stores only serialized values heavy load on page reduce page performance for massive data non secure encoded data on page level. Data Encapsulation is nothing but grouping up of related members (variables and methods) into a single unit called class Data Hiding is nothing but restricting outside access of a class members using access modifiers such as private , protected and internal etc., Suppose you have the following ServiceContract implemented: [ServiceContract] public interface IMyTask { [OperationContract(IsOneWay=false)] void MyTask(); [OperationContract(IsOneWay = true)] void MyTaskOneWay(); } By invoking the two operations from the client side and capturing the HTTP message, we can get different response messages. The normal void operation will return HTTP 200 status code and the complete SOAP Response in the body and the one-way operation will only return a HTTP 202 Accepted status header. This indicates that the one-way operation call gets finished as long as the server side received the request, while the normal void operation will wait for the server side to execute and return the response data.

What is the purpose of ExtensionDataObject in WCF? or How to make DataContract forward compatible? A .NET serialization system supports backward-compatibility on custom data types naturally. However, sometimes we also need forward-compatibility for data types used in a WCF service.ExtensionDataObject property is used to achieve the Forward compatible in WCF. Suppose that you have a service that exchanges some custom data types between clients. If one side updates the custom data type (adds some fields or properties) or uses a newer version, it is important to make sure that the other side can still work correctly with the updated data type instances without using the updated version of data. Let see how can we achieve this in WCF. 1.First we need to make our Custom Data type to implement the IExtensibleDataObject interface. [DataContract] public class Employee: IExtensibleDataObject { [DataMember] public string Name{ get; set; } [DataMember] public string Address{ get; set; } public ExtensionDataObject ExtensionData { get; set; } }

2. Next we need to make sure that we haven't enabled the IgnoreExtensionDataObject property on ServiceBehaviorAttribute applied on your WCF service .This property is disabled by default.

1.When we use the IDENT_CURRENT , it will return the last identity value generated for a specific table in any session and any scope. 2.When we use the @@IDENTITY , it will return the last identity value generated for any table in the current session, across all scopes. 3.When we use the SCOPE_IDENTITY, it will return the last identity value generated for any table in the current session and the current scope.

1. ArrayList and Generic List are used to store any type of objects.Consider that you are intended to store only the integer values.In this case when we use ArrayList , we can store any type of objects(i.e., Integer,String or some custom objects). Example: ArrayList objarList=new ArrayList(); objarList.add(123); objarList.add("senthil");// will compile..but will throw run time error. It won't throw any compile time error.It will throw only run time error when we iterate values in the array list by using for each. But when we use the Generic List ,we can restrict in the compile time itself.If you are intended to store only integer values,then it will allow to store only integer values.If you try to store any other value other than integer, then it will throw compile time error. List<int> objList=new List<int>(); objList.add(123); objList.add("senthil") // Will result in compile time error. 2.Whenever you are adding the objects in the ArrayList boxing will happen at that time.Whenever you are accessing the objects from the ArrayList unboxing will happen at that time.So it will hurt the performance. But in case of Generic List there will not be any Boxing or UnBoxing problem and also it will provide the better type safety.

VAR - DYNAMIC DIFFERENCE C#


1. 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. Example:

Var strNameList=new List<string>(); By using this statement we can store list of names in the string format. strNameList.add("Senthil"); strNameList.add("Vignesh"); strNameList.add(45); // This statement will cause the 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. Example: dynamic test="Senthil"; Console.Writeline(test.GetType()) // System.String test=1222; Console.Writeline(test.GetType()) // System.Int32 test=new List<string>(); 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. Use Dynamic when: It is better to go with dynamic type , only when our application depends heavily on Reflection services.By using Dynamic we can reduce the amount of code while we are working with reflection. If your application needs to communicate with COM components like Microsoft Office Products(i.e.MS Word,MS Excel), then we can prefer using Dynamic. If your application needs to communicate with some dynamic languages like Iron Ruby or Iron Python, then we can prefer using Dynamic. Use Var when:We work with linq.Because many linq queries will return only enumeration of anonymous classes..

2. We can use the Var keyword only for the local variables.We can't use it as a class level variables,method's parameter or method's return type. But we can use the Dynamic type as a

Class level variables, local variables,dynamic property ,dynamic parameter and dynamic return type. Class VarDynamicClass { private var MyVarField;//Not possible private dynamic MyDynField;// Possible public var MyVarProperty{get;set;}//Not possible public dynamic myDynProperty{get;set;}// Possible public var MyVarMethod(var param1) //Not possible { var dynInt=25; // Possible if(param1 is int) { return param1+dynInt; } } public dynamic MyDynamicMethod(dynamic d1) // Possible { if(d1 is int) { return d1; } } } 3.If you try to call non existing members(i.e variables or methods and so on) with dynamic type , it won't throw any compile time error. It will throw only run time error as it is not checked at compile time. But in case of var type, we can restrict in the compile time itself. Example: dynamic d=new MyObject(); d.CallNonExistingMethod()// Won't throw compile time error..will throw run time error. // Unhandled Exception: Microsoft.Csharp.RuntimeBinder.RuntimeBinderException // MyObject doesn't contain a definition for 'CallNonExistingMethod'
In the body tag write property name oncontextmenu="return false" this will stop right click on web page.. same thing write on img tag to disable right click ..

You might also like