Net

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Net as PDF for free.

More details

  • Words: 2,950
  • Pages: 7
http://www.wpftutorial.net/Mouse.html http://www.csharpcorner.com/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=191

In practice,an interface is a good way to encapsulate a common idea for use by a number of possibly unrelated classes, while an abstract class is a good way to encapsulate a common idea for use by a number of related classes. When you need to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members. An Interface can only inherit from another Interface, when an abstract class can inherit from a class and one or more interfaces An Interface cannot contain constructors or destructors, when abstract class can contain constructors or destructors. An Interface can be inherited from by structures,when abstract class cannot be inherited from by structures. An Interface can support multiple inheritance,when abstract class cannot support multiple inheritance. Interfaces are used to define the peripheral abilities of a class;An abstract class defines the core identity of a class and there it is used for objects of the same type. If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method; If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly. Abstract class V/s Interfaces:1.) Abstract class can contain data members.Interfaces can�t. 2.) Abstract class can contain non abstract methods too.Interfaces can�t. 3.) Default access specifier is abstract class is private but we can have other access specifiers also.Interfaces methods are by default public you can�t specify any access specifier not even public. 4.) In interfaces members are by default abstract you can�e even specify asbtract keyword. 5.) Abstract class can implement interfaces.Interfaces can�t inherit classes but can implement other interfaces also. 6.) You can inherit from a single base class but you can implement multiple interfaces. 7.) Abstract classes are created using abstract keyword.Interfaces are created using interface keyword.

Interface is a class which contain all unimplemented methods( can call them also abstract methods) We will implement these methods in derived class of interface. ie an interface is actually not inherited but implemented. We cann't create an instance of interface object instead we can create an instance for derived class objects...(I think this u know) If the requirement is like that something in your design changes frequently then go for interfaces instead of classes

For example if you want to your project should support different databases . so that client can change his database in future we use interfaces contains property procedures in class file with out altering objects Here is another example, the Strategy pattern lets you swap new algorithms and processes into your program without altering the objects that use them. A media player might know how to play CDs, MP3s, and wav files. Of course, you don't want to hardcode those playback algorithms into the player; that will make it difficult to add a new format like AVI. Furthermore, your code will be littered with useless case statements. And to add insult to injury, you will need to update those case statements each time you add a new algorithm. All in all, this is not a very object-oriented way to program. With the Strategy pattern, you can simply encapsulate the algorithm behind an object. If you do that, you can provide new media plug-ins at any time. Let's call the plug-in class MediaStrategy. That object would have one method: playStream(Stream s). So to add a new algorithm, we simply extend our algorithm class. Now, when the program encounters the new media type, it simply delegates the playing of the stream to our media strategy. Of course, you'll need some plumbing to properly instantiate the algorithm strategies you will need. This is an excellent place to use an interface. Thus, you should define the strategy as an interface. You should generally favor interfaces over inheritance when you want an object to have a certain type; in this case, MediaStrategy. Relying on inheritance for type identity is dangerous; it locks you into a particular inheritance hierarchy. C# doesn't allow multiple inheritance, so you can't extend something that gives you a useful implementation or more type identity. So we use interfaces

LINQ Advantages 1. LINQ syntax beats SQL syntax. SQL is flawed in that queries become exponentially difficult to write as their complexity grows. LINQ scales much better in this regard. Once you get used to it, it's hard to go back. 2. Database queries are easily composable. You can conditionally add an ORDER BY or WHERE predicate without discovering at run-time that a certain string combination generates a syntax error. 3. More bugs are picked up at compile-time. 4. Parameterization is automatic and type-safe. 5. LINQ queries can directly populate an object hierarchy. 6. LINQ to SQL provides a model for provider independence that might really work. 7. LINQ significantly cuts plumbing code and clutter. Without sweeping stuff under the carpet, like Workflow or Datasets. This is a credit to the design team. 8. C# hasn't suffered in the process (in fact, it's gained). SQL A covering index, which is a form of a composite index, includes all of the columns referenced in SELECT, JOIN, and WHERE clauses of a query. SQL Deterministic functions always returns the same output result all the time it is executed for same input values. i.e. ABS, DATEDIFF, ISNULL etc. Nondeterministic functions may return different results each time they are executed. i.e. NEWID, RAND, @@CPU_BUSY etc. Functions that call extended stored

procedures are nondeterministic. User-defined functions that create side effects on the database are not recommended. A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods. Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is accomplished outside the Method's class. In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes. An abstract class is the one that is not used to create objects. An abstract class is designed to act as a base class (to be inherited by other classes). Abstract class is a design concept in program development and provides a base upon which other classes are built. Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on it?s own, it must be inherited. Like interfaces, abstract classes can specify members that must be implemented in inheriting classes. Unlike interfaces, a class can inherit only one abstract class. Abstract classes can only specify members that should be implemented by all inheriting classes. An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn?t support multiple inheritance, interfaces are used to implement multiple inheritance. VB.Net / C# provide polymorphism through the following mechanisms: 1. Inheritance -- base class provides overridable methods which are re-implemented in derived classes. 2. Interface -- different class can implement same interface, resulting in different implementations of interface methods. 3. Virtual methods -- achieve runtime polymorphism. Assemblies are of two types 1. Private Assemblies 2. Shared Assemblies Private Assemblies: The assembly is intended only for one application. The files of that assembly must be placed in the same folder as the application or in a sub folder. No other application will be able to make a call to this assembly. The advantage of having a private assembly is that, it makes naming the assembly very easy, since the developer need not worry about name clashes with other assemblies. As long as the assembly has a unique name within the concerned application, there won't be any problems. Shared Assemblies: If the assembly is to be made into a Shared Assembly, then the naming conventions are very strict since it has to be unique across the entire system. The naming conventions should also take care of newer versions of the component being shipped. These are accomplished by giving the assembly a Shared Name. Then the assembly is placed in the global assembly cache, which is a folder in the file system reserved for shared assemblies.

ADO.NET features: 1. Disconnected Data Architecture 2. Data cached in Datasets 3. Data transfer in XML format 4. Interaction with the database is done through data commands CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately. The CLR is the execution engine for .NET Framework applications. It provides a number of services, including: � � Code management (loading and execution) � Application memory isolation � Verification of type safety � Conversion of IL to native code. � Access to metadata (enhanced type information) � Managing memory for managed objects � Enforcement of code access security � Exception handling, including cross-language exceptions � Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data) � Automation of object layout � Support for developer services (profiling, debugging, and so on). What are Attributes? Attributes are declarative tags in code that insert additional metadata into an assembly. There exist two types of attributes in the .NET Framework: Predefined attributes such as Assembly Version, which already exist and are accessed through the Runtime Classes; and custom attributes, which you write yourself by extending the System. Attribute class. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn?t support multiple inheritance, interfaces are used to implement multiple inheritance. A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods. Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is

accomplished outside the Method's class. User control 1.Compiled at runtime 2.HTML design (Visual design possible) 3.ASP.Net page model with code behind 4.Needs ASP.NET .aspx page to exist (can be used) 5.No design time interface (Only a box representing the user control is available on an .aspx page) 6.Cannot be added to the ToolBox Custom Server Control 1.Precompiled 2.No visual design. HTML needs to be declared programmatically 3.Component model 4.can be used in .aspx pages, user controls or other custom server controls. 5.Has design-time and run-time interface 6. Can be added to the ToolBox (using drag and drop) 1.Datagrid has paging while Datalist doesnt. 2. Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid. 3. A repeater is used when more intimate control over html generation is required. 4. When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than a Datagrid. The Repeater repeats a chunk of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you RepeatColumns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you�re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default. Out of the 3 controls, I use the Repeater the most due to its flexibility w/ HTML. Creating a Pagination scheme isn't that hard, so I rarely if ever use a DataGrid. Occasionally I like using a DataList because it allows me to easily list out my records in rows of three for instance. CLR(Common Language Runtime) is the main resource of .Net Framework. it is collection of services like garbage collector, exception handler, jit compilers etc. with the CLR cross language integration is possible. A thread is a path of execution that run on CPU, a process is a collection of threads that share the same virtual memory. A process has at least one thread of execution, and a thread always run in a process context.

What are the different state management techniques used in asp.net for web applications? In ASP.Net the state can be maintained in following ways Server-side state management Application objects Session Variables Database Client-side state management Cookies Hidden input fields Query String ViewState Multiple inheritance is possible in .Net through Interfaces. If we add a new method to an Interface then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly. .NET does not encourage the development of COM components and provides a different solution to making reusable components through Assemblies. But, there are a lot of COM components present which our .Net application might need to use. Fortunately, .Net provides an extremely simple approach to achieve this. This is achieved by using �Wrapper Classes� and �Proxy Components�. .Net wraps the COM component into .Net assembly technically called �Runtime Callable Wrapper� or RCW. Then u can call and use your COM component just as a .Net (or C#, if u are using C#) Assembly. XSLT is based on template rules which specify how XML documents should be processed. An XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it produce a new XML document. With XSLT we can also produce HTML or XHTML from XML document. With XSLT we can add/remove elements and attributes, rearrange and sort elements, hide and display elements from the output file. Converting XML to HTML for display is probably the most common application of XSLT today. In Microsoft.Net a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key. A struct is a value type, while a class is a reference type. When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack. Classes can have explicit parameter less constructors. But structs cannot have this. Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces. We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type. We can declare a destructor in class but can not in struct. In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility

modifiers. The terms "deep copy" and "shallow copy" refer to the way objects are copied. VB.NET/C#.NET Languages CTS CLS Web Forms/window Forms/Console Framework Class Library ADO.NET CLR OS The MyBase keyword behaves like an object variable referring to the base class of the current instance of a class. MyBase is commonly used to access base class members that are overridden or shadowed in a derived class. In particular, MyBase.New is used to explicitly call a base class constructor from a derived class constructor. You can't have a overload method with same number parameters but different return type. In order to create overload method, the return type must be the same and parameter type must be different or different in numbers. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override. Property - Attribute of Object - like User -> Name, Email, Address, Country..... Difference between Struct and Class 1) Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap. 2) Struct �do not support� inheritance, while class supports inheritance. However struct can implements interface. 3) Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.

Related Documents

Net
November 2019 45
Net
May 2020 23
Net
October 2019 36
Net
April 2020 24
Net
May 2020 24
Net
December 2019 29