1. How big is the datatype int in .NET? 32 bits.
2. How big is the char? 16 bits (Unicode).
3. How do you initiate a string without escaping each backslash?
Put an @ sign in front of the double-quoted string.
4. What are valid signatures for the Main function?
1. public static void Main()
2. public static int Main()
3. public static void Main( string[] args )
4. public static int Main(string[] args )
5. Does Main() always have to be public? No.
6. How do you initialize a two-dimensional array that you don’t
know the dimensions of?
1. int [, ] myArray; //declaration
2. myArray= new int [5, 8]; //actual initialization
7. What’s the access level of the visibility type internal? Current assembly.
8. What’s the difference between struct and class in C#?
1. Structs cannot be inherited.
2. Structs are passed by value, not by reference.
3. Struct is stored on the stack, not the heap.
9. Explain encapsulation. The implementation is hidden, the interface is exposed.
10. What data type should you use if you want an 8-bit value that’s signed? sbyte.
11. Speaking of Boolean data types, what’s different between C# and C/C++?
There’s no conversion between 0 and false, as well as any other number
and true, like in C/C++.
12. Where are the value-type variables allocated in the computer RAM? Stack.
13. Where do the reference-type variables go in the RAM?
The references go on the stack, while the objects themselves go on the heap.
However, in reality things are more elaborate.
14. What is the difference between the value-type variables and reference-type
variables in
terms of garbage collection?
The value-type variables are not garbage-collected, they just fall off the
stack when they fall out of scope, the reference-type objects are picked up
by GC when their references
go null.
15. How do you convert a string into an integer in .NET?
Int32.Parse(string),Convert.ToInt32()
16. How do you box a primitive data type variable?
Initialize an object with its value, pass an object, cast it to an object
17. Why do you need to box a primitive variable?
To pass it by reference or apply a method that an object supports, but primitive
doesn’t.
18. What’s the difference between Java and .NET garbage collectors?
Sun left the implementation of a specific garbage collector up to the JRE developer,
so their performance varieswidely, depending on whose JRE you’re using.
Microsoft standardized on their garbage collection.
19. How do you enforce garbage collection in .NET?
System.GC.Collect();
20. Can you declare a C++ type destructor in C# like ~MyClass()?
Yes, but what’s the point, since it will call Finalize(), and Finalize()
has no guarantees when the memory will be cleaned up, plus,it introduces additional
load on the garbage collector. The only time the finalizer should be
implemented, is when you’re dealing with unmanaged code.
21. What’s different about namespace declaration when comparing that
to package
declaration in Java?
No semicolon. Package declarations also have to be the first thing within the
file,can’t be nested, and affect all classes within the file.
22. What’s the difference between const and readonly?
You can initialize readonly variables to some runtime values. Let’s say
your program uses current date and time as one of the values that won’t
change. This way you declare
public readonly string DateT = new DateTime().ToString().
23. Can you create enumerated data types in C#? Yes.
24. What’s different about switch statements in C# as compared to C++?
No fall-throughs allowed.
25. What happens when you encounter a continue statement inside the for loop?
The code for the rest of the loop is ignored, the control is transferred back
to the beginning of the loop.
26. Is goto statement supported in C#? How about Java?
Gotos are supported in C#to the fullest. In Java goto is a reserved keyword
that provides absolutely no functionality.
27. Describe the compilation process for .NET code?
Source code is compiled and run in the .NET Framework using a two-stage process.
First, source code is compiled to Microsoft intermediate language (MSIL) code
using a .NET Framework-compatible compiler, such as that for Visual Basic.NET
or Visual C#. Second, MSIL code is compiled to native code.
28. Name any 2 of the 4 .NET authentification methods.
ASP.NET, in conjunction with Microsoft Internet Information Services (IIS),
can authenticate user credentials such as names and passwords using any of the
following authentication methods:
1. Windows: Basic, digest, or Integrated Windows Authentication (NTLM or Kerberos).
2. Microsoft Passport authentication
3. Forms authentication
4. Client Certificate authentication
29. How do you turn off SessionState in the web.config file?
In the system.web section ofweb.config, you should locate the httpmodule tag
and you simply disable session by doing a remove tag with attribute name set
to session.
<httpModules>
<remove name="Session” />
</httpModules>
30. What is main difference between Global.asax and Web.Config?
ASP.NET uses theglobal.asax to establish any global objects that your Web application
uses. The .asax extension denotes an application file rather than .aspx for
a page file. Each ASP.NET application can contain at most one
global.asax file. The file is compiled on the first page hit to your Web application.
ASP.NET is also
configured so that any attempts to browse to the global.asax page directly are
rejected. However, you
can specify application-wide settings in the web.config file. The web.config
is an XML-formatted text
file that resides in the Web site’s root directory. Through Web.config
you can specify settings like
custom 404 error pages, authentication and authorization settings for the Web
site, compilation options
for the ASP.NET Web pages, if tracing should be enabled, etc.
31. Whats an assembly?
Assemblies are the building blocks of .NET Framework applications;they form
the fundamental unit of deployment, version control, reuse, activation scoping,
and security permissions. An assembly is a collection of types and resources
that are built to work together and form a logical unit of functionality. An
assembly provides the common language runtime with the information it needs
to be aware of type implementations. To the runtime, a type does not exist outside
the context of an assembly.
32. 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 <script 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.
33. Explain what a diffgram is, and a good use for one?
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.
34. Where would you use an iHTTPModule, and what are the limitations of anyapproach
you might take in implementing one?
One of ASP.NET’s most useful features is the extensibility of the HTTP
pipeline, the path that data takes between client and server. You can use them
to extend your ASP.NET applications by adding pre- and post-processing to each
HTTP request coming into your application. For example, if you wanted custom
authentication facilities for your application, the best technique would be
to intercept the request when it comes in and process the request in a custom
HTTP module.
35. What are the disadvantages of viewstate/what are the benefits?
36. Describe session handling in a webfarm, how does it work and what are the
limits?
37. How would you get ASP.NET running in Apache web servers - why would you
even do
this?
38. Whats MSIL, and why should my developers need an appreciation of it if at
all?
39. In what order do the events of an ASPX page execute. As a developer is it
important to
undertsand these events?
Every Page object (which your .aspx page is) has nine events, most of which
you will not have to worry about in your day to day dealings with ASP.NET. The
three that you will
deal with the most are: Page_Init, Page_Load, Page_PreRender.
40. Which method do you invoke on the DataAdapter control to load your generated
dataset
with data?
System.Data.Common.DataAdapter.Fill(System.Data.DataSet); If my DataAdapter
is sqlDataAdapter and my DataSet is dsUsers then it is called this way: sqlDataAdapter.Fill(dsUsers);
41. ata in the Repeater control?
42. Which template must you provide, in order to display data in a Repeater
control?
ItemTemplate
43. How can you provide an alternating color scheme in a Repeater control?
AlternatingItemTemplate Like the ItemTemplate element, but rendered for every
other
row (alternating items) in the Repeater control. You can specify a different
appearance
for the AlternatingItemTemplate element by setting its style properties.
44. What property must you set, and what method must you call in your code,
in order to
bind the data from some data source to the Repeater control?
You must set the DataMember property which Gets or sets the specific table in
the DataSource to bind
to the control and the DataBind method to bind data from a source to a server
control. This method is
commonly used after retrieving a data set through a database query.
45. What base class do all Web Forms inherit from? System.Web.UI.Page
46. What method do you use to explicitly kill a user’s session?
The Abandon method destroys all the objects stored in a Session object and releases
their resources.
If you do not call the Abandon method explicitly, the server destroys these
objects when the session
times out.
Syntax: Session.Abandon
47. How do you turn off cookies for one page in your site?
Use the Cookie.Discard Property which Gets or sets the discard flag set by the
server. When true, this
property instructs the client application not to save the Cookie on the user’s
hard disk when a session
ends.
48. Which two properties are on every validation control?
ControlToValidate & ErrorMessage properties
49. What tags do you need to add within the asp:datagrid tags to bind columns
manually?
50. How do you create a permanent cookie?
Setting the Expires property to MinValue means that the Cookie never expires.
51. What tag do you use to add a hyperlink column to the DataGrid?
52. What is the standard you use to wrap up a call to a Web service?
53. Which method do you use to redirect the user to another page without performing
a
round trip to the client? Server.transfer()
54. What is the transport protocol you use to call a Web service?
SOAP. Transport Protocols: It is essential for the acceptance of Web Services
that they are based on established Internet infrastructure. This in fact imposes
the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family
of transports. Messaging Protocol: The format of messages exchanged between
Web
Services clients and Web Services should be vendor neutral and should not carry
details about the
technology used to implement the service. Also, the message format should allow
for extensions and
different bindings to specific transport protocols. SOAP and ebXML Transport
are specifications which
fulfill these requirements. We expect that the W3C XML Protocol Working Group
defines a successor
standard.
55. True or False: A Web service can only be written in .NET. False.
56. What does WSDL stand for? Web Services Description Language
57. What property do you have to set to tell the grid which page to go to when
using the
Pager object?
58. Where on the Internet would you look for Web services?
UDDI repositaries like uddi.microsoft.com, IBM UDDI node, UDDI Registries in
Google Directory, enthusiast sites like XMethods.net.
59. What tags do you need to add within the asp:datagrid tags to bind columns
manually?
Column tag and an ASP:databound tag.
60. Which property on a Combo Box do you set with a column name, prior to setting
the
DataSource, to display data in the combo box?
61. How is a property designated as read-only? In VB.NET:
62. Public ReadOnly Property PropertyName As ReturnType
63. Get ‘Your Property Implementation goes in here
64. End Get
End Property
in C#
public returntype PropertyName
{
get{
//property implementation goes here
}
// Do not write the set implementation
}
65. Which control would you use if you needed to make sure the values in two
different
controls matched?
Use the CompareValidator control to compare the values of 2 different controls.
66. True or False: To test a Web service you must create a windows application
or Web
application to consume this service? False.
67. How many classes can a single .NET DLL contain? Unlimited.
68. Describe the advantages of writing a managed code application instead of
unmanaged
one. What’s involved in certain piece of code being managed?
The advantages include automaticgarbage collection, memory management, support
for versioning and security. These advantages are provided through .NET FCL
and CLR, while with the unmanaged code similar capabilities had to be implemented
through third-party libraries or as a part of the application itself.
69. Are COM objects managed or unmanaged? Since COM objects were written before
.NET,
apparently they are unmanaged.
70. So can a COM object talk to a .NET object? Yes, through Runtime Callable
Wrapper
(RCW) or PInvoke.
71. How do you generate an RCW from a COM object? Use the Type Library Import
utility
shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the
COM library from Visual
Studio in your project.
72. I can’t import the COM object that I have on my machine. Did you
write that object? You
can only import your own objects. If you need to use a COM component from another
developer, you
should obtain a Primary Interop Assembly (PIA) from whoever authored the original
object.
73. How do you call unmanaged methods from your .NET code through PInvoke?
Supply a
DllImport attribute. Declare the methods in your .NET code as static extern.
Do not implement the
methods as they are implemented in your unmanaged code, you’re just providing
declarations for
method signatures.
74. Can you retrieve complex data types like structs from the PInvoke calls?
Yes, just make
sure you re-declare that struct, so that managed code knows what to do with
it.
75. I want to expose my .NET objects to COM objects. Is that possible? Yes,
but few things
should be considered first. Classes should implement interfaces explicitly.
Managed types must be
public. Methods, properties, fields, and events that are exposed to COM must
be public. Types must
have a public default constructor with no arguments to be activated from COM.
Types cannot be
abstract.
76. Can you inherit a COM class in a .NET application? The .NET Framework extends
the
COM model for reusability by adding implementation inheritance. Managed types
can derive directly or
indirectly from a COM coclass; more specifically, they can derive from the runtime
callable wrapper
generated by the runtime. The derived type can expose all the method and properties
of the COM object
as well as methods and properties implemented in managed code. The resulting
object is partly
implemented in managed code and partly implemented in unmanaged code.
77. Suppose I call a COM object from a .NET applicaiton, but COM object throws
an error.
What happens on the .NET end? COM methods report errors by returning HRESULTs;
.NET methods
report them by throwing exceptions. The runtime handles the transition between
the two. Each exception
class in the .NET Framework maps to an HRESULT.
78. Explain transaction atomicity. We must ensure that the entire transaction
is either committed
or rolled back.
79. Explain consistency. We must ensure that the system is always left at the
correct state in case
of the failure or success of a transaction.
80. Explain integrity. Ensure data integrity by protecting concurrent transactions
from seeing or
being adversely affected by each other’s partial and uncommitted results.
81. Explain durability. Make sure that the system can return to its original
state in case of a
failure.
82. Explain object pooling. With object pooling, COM+ creates objects and keeps
them in a pool,
where they are ready to be used when the next client makes a request. This improves
the performance of
a server application that hosts the objects that are frequently used but are
expensive to create.
83. Explain JIT activation. The objective of JIT activation is to minimize
the amount of time for
which an object lives and consumes resources on the server. With JIT activation,
the client can hold a
reference to an object on the server for a long time, but the server creates
the object only when the client
calls a method on the object. After the method call is completed, the object
is freed and its memory is
reclaimed. JIT activation enables applications to scale up as the number of
users increases.
84. Explain role-based security. In the role-based security model, access to
parts of an
application are granted or denied based on the role to which the callers belong.
A role defines which
members of a Windows domain are allowed to work with what components, methods,
or interfaces.
85. Explain queued components. The queued components service enables you to
create
components that can execute asynchronously or in disconnected mode. Queued components
ensure
availability of a system even when one or more sub-systems are temporarily unavailable.
Consider a
scenario where salespeople take their laptop computers to the field and enter
orders on the go. Because
they are in disconnected mode, these orders can be queued up in a message queue.
When salespeople
connect back to the network, the orders can be retrieved from the message queue
and processed by the
order processing components on the server.
86. Explain loosely coupled events. Loosely coupled events enable an object
(publisher) to
publish an event. Other objects (subscribers) can subscribe to an event. COM+
does not require
publishers or subscribers to know about each other. Therefore, loosely coupled
events greatly simplify
the programming model for distributed applications.
87. Define scalability. The application meets its requirement for efficiency
even if the number of
users increases.
88. Define reliability. The application generates correct and consistent information all the time.
89. Define availability. Users can depend on using the application when needed.
90. Define security. The application is never disrupted or compromised by the
efforts of malicious
or ignorant users.
91. Define manageability. Deployment and maintenance of the application is
as efficient and
painless as possible.
92. Which namespace do the classes, allowing you to support COM functionality,
are
located? System.EnterpriseServices
93. How do you make a NET component talk to a COM component? To enable the
communication between COM and .NET components, the .NET Framework generates
a COM Callable
Wrapper (CCW). The CCW enables communication between the calling COM code and
the managed
code. It also handles conversion between the data types, as well as other messages
between the COM
types and the .NET types.
94. Explain Windows service. You often need programs that run continuously
in the background.
For example, an email server is expected to listen continuously on a network
port for incoming email
messages, a print spooler is expected to listen continuously to print requests,
and so on.
95. What’s the Unix name for a Windows service equivalent? Daemon.
96. So basically a Windows service application is just another executable?
What’s different
about a Windows service as compared to a regular application? Windows services
must support the
interface of the Service Control Manager (SCM). A Windows service must be installed
in the Windows
service database before it can be launched.
97. How is development of a Windows service different from a Windows Forms
application?
A Windows service typically does not have a user interface, it supports a set
of commands and can have
a GUI that’s built later to allow for easier access to those commands.
98. How do you give a Windows service specific permissions? Windows service
always runs
under someone’s identity. Can be System or Administrator account, but
if you want to restrict the
behavior of a Windows service, the best bet is to create a new user account,
assign and deny necessary
privileges to that account, and then associate the Windows service with that
new account.
99. Can you share processes between Windows services? Yes.
100. Where’s Windows service database located?
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
![]() |
![]() |