Академический Документы
Профессиональный Документы
Культура Документы
Net FAQ
NET FrameWork FAQ's
When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC
had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of
the .NET framework/SDK and Visual Studio.NET.
When was the first version of .NET released?
The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the
same time, the final version of Visual Studio.NET was made available to MSDN subscribers.
What platforms does the .NET Framework run on?
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported.
Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows
XP and Windows 2000. Windows 98/ME cannot be used for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the
ASP.NET Web Matrix web server does run on XP Home.
The Mono project is attempting to implement the .NET framework on Linux.
What is the CLR?
CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can
take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR
resources in his MSDN PDC# article:
Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection)
Security model
Type system
All .NET base classes
Many .NET framework classes
Development, debugging, and profiling tools
Execution and code management
IL-to-native translators and optimizers
What this means is that in the .NET world, different programming languages will be more equal in capability than
they have ever been before, although clearly not all languages will support all CLR services.
What is the CTS?
CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that
.NET applications can use. However note that not all .NET languages will support all the types in the CTS. The
CTS is a superset of the CLS.
What is the CLS?
CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to
support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program
written in any language.
In theory this allows very tight interop between different .NET languages - for example allowing a C# class to
inherit from a VB class.
What is IL?
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common
Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to
machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
What does 'managed' mean in the .NET context?
The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly
different things.Managed code: The .NET framework provides several core run-time services to the programs that
run within it - for example
exception handling and security. For these services to work, the code must provide a minimum level of information
to the runtime.
Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not
managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).
Managed data: This is data that is allocated and de-allocated by the .NET runtime's garbage collector. C# and
VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but
10
11
12
13
Security
Type Identity
Reference Scope
Versioning
Deployment
Global Assembly Cache :-- Assemblies can be shared among multiple applications on the machine by registering
them in global Assembly cache(GAC). GAC is a machine wide a local cache of assemblies maintained by the .NET
Framework. We can register the assembly to global assembly cache by using gacutil command.
We can Navigate to the GAC directory, C:\winnt\Assembly in explore. In the tools menu select the cache
properties; in the windows displayed you can set the memory limit in MB used by the GAC
MetaData :--Assemblies have Manifests. This Manifest contains Metadata information of the Module/Assembly as
well as it contains detailed Metadata of other assemblies/modules references (exported). It's the Assembly Manifest
which differentiates between an Assembly and a Module.
What are the mobile devices supported by .net platform
The Microsoft .NET Compact Framework is designed to run on mobile devices such as mobile phones, Personal
Digital Assistants (PDAs), and embedded devices. The easiest way to develop and test a Smart Device Application
is to use an emulator.
These devices are divided into two main divisions:
1) Those that are directly supported by .NET (Pocket PCs, i-Mode phones, and WAP devices)
2) Those that are not (Palm OS and J2ME-powered devices).
What is GUID , why we use it and where?
GUID :-- GUID is Short form of Globally Unique Identifier, a unique 128-bit number that is produced by the
Windows OS or by some Windows applications to identify a particular component, application, file, database entry,
and/or user. For instance, a Web site may generate a GUID and assign it to a user's browser to record and track the
session. A GUID is also used in a Windows registry to identify COM DLLs. Knowing where to look in the registry
and having the correct GUID yields a lot information about a COM object (i.e., information in the type library, its
physical location, etc.). Windows also identifies user accounts by a username (computer/domain and username) and
assigns it a GUID. Some database administrators even will use GUIDs as primary key values in databases.
GUIDs can be created in a number of ways, but usually they are a combination of a few unique settings based on
specific point in time (e.g., an IP address, network MAC address, clock date/time, etc.).
Describe the difference between inline and code behind - which is best in a loosely coupled solution
ASP.NET supports two modes of page development: Page logic code that is written inside runat="server"> blocks
within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that
is written within an external class that is compiled prior to deployment on a server and linked ""behind"" the .aspx
file at run time.
Whats MSIL, and why should my developers need an appreciation of it if at all?
When compiling the source code to managed code, the compiler translates the source into Microsoft intermediate
language (MSIL). This is a CPU-independent set of instructions that can efficiently be converted to native code.
Microsoft intermediate language (MSIL) is a translation used as the output of a number of compilers. It is the input
to a just-in-time (JIT) compiler. The Common Language Runtime includes a JIT compiler for the conversion of
MSIL to native code.
Before Microsoft Intermediate Language (MSIL) can be executed it, must be converted by the .NET Framework
just-in-time (JIT) compiler to native code. This is CPU-specific code that runs on the same computer architecture as
the JIT compiler. Rather than using time and memory to convert all of the MSIL in a portable executable (PE) file
14
15
16
17
18
19
20
21
22
23
24
25
WinForms FAQ
What base class do all Web Forms inherit from?
System.Windows.Forms.Form
What is the difference between Debug.Write and Trace.Write? When should each be used?
The Debug.Write call won't be compiled when the DEBUGsymbol is not defined (when doing a release build).
Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is
for when you want it in release build as well.
Difference between Anchor and Dock Properties?
Dock Property->Gets or sets which edge of the parent container a control is docked to. A control can be docked to
one edge of its parent container or can be docked to all edges and fill the parent container. For example, if you set
this property to DockStyle.Left, the left edge of the
control will be docked to the left edge of its parent control. Additionally, the docked edge of the control is resized
to match that of its container
control.
Anchor Property->Gets or sets which edges of the control are anchored to the edges of its container. A control can
be anchored to one or more edges of its parent container. Anchoring a control to its parent ensures that the anchored
edges remain in the same position relative to the edges of the parent container when the parent container is resized.
When would you use ErrorProvider control?
ErrorProvider control is used in Windows Forms application. It is like Validation Control for ASP.NET pages.
ErrorProvider control is used to provide validations in Windows forms and display user friendly messages to the
user if the validation fails.
E.g
If we went to validate the textBox1 should be empty, then we can validate as below
1). You need to place the errorprovide control on the form
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
ValidateName();
}
private bool ValidateName()
{
bool bStatus = true;
if (textBox1.Text == "")
{
errorProvider1.SetError (textBox1,"Please enter your Name");
bStatus = false;
}
else
errorProvider1.SetError (textBox1,"");
return bStatus;
}
it check the textBox1 is empty . If it is empty, then a message Please enter your name is displayed.
Can you write a class without specifying namespace? Which namespace does it belong to by default??
Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally,
you wouldn't want global namespace.
26
27
With these events, why wouldn't Microsoft combine Invalidate and Paint, so that you wouldn't have to tell it
to repaint, and then to force it to repaint?
Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the process to
take place in the background.
How can you assign an RGB color to a System.Drawing.Color object?
Call the static method FromArgb of this class and pass it the RGB values.
What class does Icon derive from?
Isn't it just a Bitmap with a wrapper name around it? No, Icon lives in System.Drawing namespace. It's not a
Bitmap by default, and is treated separately by .NET. However, you can use ToBitmap method to get a valid Bitmap
object from a valid Icon object.
Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET
dynamically?
By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning produces an
Icon with a warning sign in it.
When displaying fonts, what's the difference between pixels, points and ems?
A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on user's settings and monitor
size. A point is always 1/72 of an inch. An em is the number of pixels that it takes to display the letter M.
28
ASP.NET FAQ's
What is view state and use of it?
The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page.
ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which
allows you to program accordingly.
What are user controls and custom controls?
Custom controls:
A control authored by a user or a third-party software vendor that does not belong to the .NET Framework class library. This
is a generic term that includes user controls. A custom server control is used in Web Forms (ASP.NET pages). A custom client
control is used in Windows Forms applications.
User Controls:
In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used as a server control. An ASP.NET user
control is authored declaratively and persisted as a text file with an .ascx extension. The ASP.NET page framework compiles a
user control on the fly to a class that derives from the
System.Web.UI.UserControl class.
What are the validation controls?
A set of server controls included with ASP.NET that test user input in HTML and Web server controls for programmer-defined
requirements. Validation controls perform input checking in server code. If the user is working with a browser that supports
DHTML, the validation controls can also perform validation using client script.
What's the difference between Response.Write() andResponse.Output.Write()?
The latter one allows you to write formattedoutput.
What methods are fired during the page load? Init()
When the page is instantiated, Load() - when the page is loaded into server memory,PreRender () - the brief moment before
the page is displayed to the user as HTML, Unload() - when page finishes loading.
Where does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
Where do you store the information about the user's locale?
System.Web.UI.Page.Culture
What's the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
CodeBehind is relevant to Visual Studio.NET only.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents
caching of a Web page that shows the current time.
What does AspCompat="true" mean and when should I use it?
AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set to true in any ASPX file that
creates apartment-threaded COM objects--that is, COM objects registered ThreadingModel=Apartment. That includes all COM
objects written with Visual Basic 6.0. AspCompat should also be set to true (regardless of threading model) if the page
creates COM objects that access intrinsic ASP objects such as Request and Response. The following directive sets AspCompat
to true:
<%@ Page AspCompat="true" %>
Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available
to the COM components by
placing unmanaged wrappers around the equivalent ASP.NET objects. Second, it improves the performance of calls that the
page places to apartment- threaded COM objects by ensuring that the page (actually, the thread that processes the request for
the page) and the COM objects it creates share an apartment. AspCompat="true" forces ASP.NET request threads into singlethreaded apartments (STAs). If those threads create COM objects marked ThreadingModel=Apartment, then the objects are
created in the same STAs as the threads that created them. Without AspCompat="true," request threads run in a multithreaded
apartment (MTA) and each call to an STA-based COM object incurs a performance hit when it's marshaled across apartment
boundaries.
Do not set AspCompat to true if your page uses no COM objects or if it uses COM objects that don't access ASP intrinsic
objects and that are registered ThreadingModel=Free or ThreadingModel=Both.
Can two different programming languages be mixed in a single ASMX file?
No.
What namespaces are imported by default in ASMX files?
The following namespaces are imported by default. Other namespaces must be imported manually. System,
System.Collections,System.ComponentModel,System.Data, System.Diagnostics,System.Web,System.Web.Services
How do I provide information to the Web Service when the information is required as a SOAP Header?
The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET's Add Web Reference menu
option. If you happen to download a WSDL file for a Web Service that requires a SOAP header, .NET will create a SoapHeader
class in the proxy source file. Using the previous example:
public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public AuthToken AuthTokenValue;
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/", IsNullable=false)]
public class AuthToken : SoapHeader {
public string Token; }}
In this case, when you create an instance of the proxy in your main application file, you'll also create an instance of the
AuthToken class and assign the string:
Service1 objSvc = new Service1();
processingobjSvc.AuthTokenValue = new AuthToken();
43
Remoting FAQ's
What distributed process frameworks outside .NET do you know?
Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model
(DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).
What are possible implementations of distributed applications in .NET?
.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in
System.Runtime.Remoting and System.Web.Services.
When would you use .NET Remoting and when Web services?
Use remoting for more efficient exchange of information when you control both ends of the application. Use Web services
for open-protocol-based information exchange when you are just a client or a server with the other end belonging to
someone else.
What's a proxy of the server object in .NET Remoting?
It's a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the
communication between real server object and the client object. This process is also known as marshaling.
What are remotable objects in .NET Remoting?
Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a
deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to
an existing object is passed.
What are channels in .NET Remoting?
Channels represent the objects that transfer the other serialized objects from one application domain to another and from one
computer to another, as well as one process to another on the same box. A channel must exist before an object can be
transferred.
What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at
application or server level.
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and
decoding messages into data on the other end.
Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?
Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
What's SingleCall activation mode used for?
If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
What's Singleton activation mode?
A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime
lease.
44
Remoting
Webservices
Yes, Choose Web Services because it is
more flexible in that they are support
SOAP.
Complex Programming
Yes
No
State Management
Transport Protocol
45
46
ADO.NET
Explain what a diffgram is and its usage ?
A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the
DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a
DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the
contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions,
row error information, and row order.
When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used. Additionally, when
loading the contents of a DataSet from XML using the ReadXml method, or when writing the contents of a DataSet in XML
using the WriteXml method, you can select that the contents be read or written as a DiffGram.
The DiffGram format is divided into three sections: the current data, the original (or "before") data, and an errors section, as
shown in the following example.
<?xml version="1.0"?>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DataInstance>
</DataInstance>
<diffgr:before>
</diffgr:before>
<diffgr:errors>
</diffgr:errors>
</diffgr:diffgram>
The DiffGram format consists of the following blocks of data:
<DataInstance>
The name of this element, DataInstance, is used for explanation purposes in this documentation. A DataInstance element
represents a DataSet or a row of a DataTable. Instead of DataInstance, the element would contain the name of the DataSet or
DataTable. This block of the DiffGram format contains the current data, whether it has been modified or not. An element, or
row, that has been modified is identified with the diffgr:hasChanges annotation.
<diffgr:before>
This block of the DiffGram format contains the original version of a row. Elements in this block are matched to elements in the
DataInstance block using the diffgr:id annotation.
<diffgr:errors>
This block of the DiffGram format contains error information for a particular row in the DataInstance block. Elements in this
block are matched to elements in the DataInstance block using the diffgr:id annotation.
Which method do you invoke on the DataAdapter control to load your generated dataset with data?
You have to use the Fill method of the DataAdapter control and pass the dataset object as an argument to load the generated
data.
Can you edit data in the Repeater control?
NO.
Which are the different IsolationLevels ?
Following are the various IsolationLevels:
Serialized Data read by a current transaction cannot be changed by another transaction until the current transaction
finishes. No new data can be inserted that would affect the current transaction. This is the safest isolation level and is
the default.
Repeatable Read Data read by a current transaction cannot be changed by another transaction until the current
transaction finishes. Any type of new data can be inserted during a transaction.
Read Committed A transaction cannot read data that is being modified by another transaction that has not committed.
This is the default isolation level in Microsoft SQL Server.
Read Uncommitted A transaction can read any data, even if it is being modified by another transaction. This is the
least safe isolation level but allows the highest concurrency.
47
Any Any isolation level is supported. This setting is most commonly used by downstream components to avoid
conflicts. This setting is useful because any downstream component must be configured with an isolation level that is
equal to or less than the isolation level of its immediate upstream component. Therefore, a downstream component
that has its isolation level configured as Any always uses the same isolation level that its immediate upstream
component uses. If the root object in a transaction has its isolation level configured to Any, its isolation level becomes
Serialized.
How xml files and be read and write using dataset?.
DataSet exposes method like ReadXml and WriteXml to read and write xml
What are the different rowversions available?
There are four types of Rowversions.
Current:
The current values for the row. This row version does not exist for rows with a RowState of Deleted.
Default :
The row the default version for the current DataRowState. For a DataRowState value of Added, Modified or Current, the
default version is Current. For a DataRowState of Deleted, the version is Original. For a DataRowState value of Detached, the
version is Proposed.
Original:
The row contains its original values.
Proposed:
The proposed values for the row. This row version exists during an edit operation on a row, or for a row that is not part of a
DataRowCollection
Explain acid properties?.
The term ACID conveys the role transactions play in mission-critical applications. Coined by transaction processing pioneers,
ACID stands for atomicity, consistency, isolation, and durability.
These properties ensure predictable behavior, reinforcing the role of transactions as all-or-none propositions designed to reduce
the management load when there are many variables.
Atomicity
A transaction is a unit of work in which a series of operations occur between the BEGIN TRANSACTION and END
TRANSACTION statements of an application. A transaction executes exactly once and is atomic all the work is done or
none of it is.
Operations associated with a transaction usually share a common intent and are interdependent. By performing only a subset of
these operations, the system could compromise the overall intent of the transaction. Atomicity eliminates the chance of
processing a subset of operations.
Consistency
A transaction is a unit of integrity because it preserves the consistency of data, transforming one consistent state of data into
another consistent state of data.
Consistency requires that data bound by a transaction be semantically preserved. Some of the responsibility for maintaining
consistency falls to the application developer who must make sure that all known integrity constraints are enforced by the
application. For example, in developing an application that transfers money, you should avoid arbitrarily moving decimal
points during the transfer.
Isolation
A transaction is a unit of isolation allowing concurrent transactions to behave as though each were the only transaction
running in the system.
Isolation requires that each transaction appear to be the only transaction manipulating the data store, even though other
transactions may be running at the same time. A transaction should never see the intermediate stages of another transaction.
Transactions attain the highest level of isolation when they are serializable. At this level, the results obtained from a set of
concurrent transactions are identical to the results obtained by running each transaction serially. Because a high degree of
isolation can limit the number of concurrent transactions, some applications reduce the isolation level in exchange for better
throughput.
Durability
A transaction is also a unit of recovery. If a transaction succeeds, the system guarantees that its updates will persist, even if the
computer crashes immediately after the commit. Specialized logging allows the system's restart procedure to complete
unfinished operations, making the transaction durable.
Whate are different types of Commands available with DataAdapter ?
The SqlDataAdapter has SelectCommand, InsertCommand, DeleteCommand and UpdateCommand
What is a Dataset?
Datasets are the result of bringing together ADO and XML. A dataset contains one or more data of tabular XML, known as
48
49
50
C# and VB.NET
Explain the differences between Server-side and Client-side code?
Server side code executes on the server.For this to occur page has to be submitted or posted back.Events fired by the controls
are executed on the server.Client side code executes in the browser of the client without submitting the page.
e.g. In ASP.NET for webcontrols like asp:button the click event of the button is executed on the server hence the event handler
for the same in a part of the code-behind (server-side code). Along the server-side code events one can also attach client side
events which are executed in the clients browser i.e. javascript events.
How does VB.NET/C# achieve polymorphism?
Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also describe the methods that a class needs
to implement. The difference between abstract classes and interfaces is that abstract classes always act as a base class of the
related classes in the class hierarchy. For example, consider a hierarchy-car and truck classes derived from four-wheeler class;
the classes two-wheeler and four-wheeler derived from an abstract class vehicle. So, the class 'vehicle' is the base class in the
class hierarchy. On the other hand dissimilar classes can implement one interface. For example, there is an interface that
compares two objects. This interface can be implemented by the classes like box, person and string, which are unrelated to each
other.
C# allows multiple interface inheritance. It means that a class can implement more than one interface. The methods declared in
an interface are implicitly abstract. If a class implements an interface, it becomes mandatory for the class to override all the
methods declared in the interface, otherwise the derived class would become abstract.
Can you explain what inheritance is and an example of when you might use it?
The savingaccount class has two data members-accno that stores account number, and trans that keeps track of the number of
transactions. We can create an object of savingaccount class as shown below.
savingaccount s = new savingaccount ( "Amar", 5600.00f ) ;
From the constructor of savingaccount class we have called the two-argument constructor of the account class using the base
keyword and passed the name and balance to this constructor using which the data member's name and balance are initialised.
We can write our own definition of a method that already exists in a base class. This is called method overriding. We have
overridden the deposit( ) and withdraw( ) methods in the savingaccount class so that we can make sure that each account
maintains a minimum balance of Rs. 500 and the total number of transactions do not exceed 10. From these methods we have
called the base class's methods to update the balance using the base keyword. We have also overridden the display( ) method to
display additional information, i.e. account number.
Working of currentaccount class is more or less similar to that of savingaccount class.
Using the derived class's object, if we call a method that is not overridden in the derived class, the base class method gets
executed. Using derived class's object we can call base class's methods, but the reverse is not allowed.
Unlike C++, C# does not support multiple inheritance. So, in C# every class has exactly one base class.
Now, suppose we declare reference to the base class and store in it the address of instance of derived class as shown below.
account a1 = new savingaccount ( "Amar", 5600.00f ) ;
account a2 = new currentaccount ( "MyCompany Pvt. Ltd.", 126000.00f) ;
Such a situation arises when we have to decide at run-time a method of which class in a class hierarchy should get called.
Using a1 and a2, suppose we call the method display( ), ideally the method of derived class should get called. But it is the
method of base class that gets called. This is because the compiler considers the type of reference (account in this case) and
resolves the method call. So, to call the proper method we must make a small change in our program. We must use the virtual
keyword while defining the methods in base class as shown below.
public virtual void display( ) { }
We must declare the methods as virtual if they are going to be overridden in derived class. To override a virtual method in
derived classes we must use the override keyword as given below.
public override void display( ) { }
Now it is ensured that when we call the methods using upcasted reference, it is the derived class's method that would get called.
Actually, when we declare a virtual method, while calling it, the compiler considers the contents of the reference rather than its
type.
If we don't want to override base class's virtual method, we can declare it with new modifier in derived class. The new modifier
indicates that the method is new to this class and is not an override of a base class method.
How would you implement inheritance using VB.NET/C#?
When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive
our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of
some other application or .NET assembly, or we may create it as part of our existing application. Once we have a base class, we
can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the
51
52
53
54
Events use delegates so clients can give the application events to call when the event is fired. Exposing custom events
within your applications requires the use of delegates.
How does the XmlSerializer work?
XmlSerializer in the .NET Framework is a great tool to convert Xml into runtime objects and vice versa
If you define integer variable and a object variable and a structure then how those will be plotted in memory.
Integer , structure System.ValueType -- Allocated memory on stack , infact integer is primitive type recognized and allocated
memory by compiler itself .
Infact , System.Int32 definition is as follows :
[C#]
[Serializable]
public struct Int32 : IComparable, IFormattable, IConvertible
So , its a struct by definition , which is the same case with various other value types .
Object Base class , that is by default reference type , so at runtime JIT compiler allocates memory on the Heap Data
structure .
Reference types are defined as class , derived directly or indirectly by System.ReferenceType
55