Core Java
Core Java
Console applications
Windows Forms applications
Windows Presentation Foundation (WPF) applications
Web applications ([Link] applications)
Web services
Windows services
Service-oriented applications using Windows Communication Foundation
(WCF)
Workflow-enabled applications using Windows Workflow Foundation (WF)
1
3. List the new features added in .NET Framework 4.0.
4. What is an IL?
5. What is Manifest?
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed
to do the following things
Version of assembly.
Security identity.
Scope of the assembly.
Resolve references to resources and classes.
The assembly manifest can be stored in a PE file either (an .exe or) .dll with
Microsoft
intermediate language (MSIL code with Microsoft intermediate language (MSIL)
code or in a
stand-alone PE file, that contains only assembly manifest information.
Code contracts help you to express the code assumptions and statements stating the
behavior of your code in a language-neutral way. The contracts are included in the
form of pre-conditions, post-conditions and object-invariants. The contracts help you
to improve-testing by enabling run-time checking, static contract verification, and
documentation generation.
2
The [Link] namespace contains static classes that are used to
express contracts in your code.
The following two new classes are introduced in the [Link] namespace:
Memory-mapped files (MMFs) allow you map the content of a file to the logical
address of an application. These files enable the multiple processes running on the
same machine to share data with each Other.
[Link]() method is used to obtain
a MemoryMappedFile object that represents a persisted memory-mapped file from a
file on disk.
CTS is the component of CLR through which .NET Framework provides support for
multiple languages because it contains a type system that is common across all the
languages. Two CTS-compliant languages do not require type conversion when
calling the code written in one language from within the code written in another
language. CTS provide a base set of data types for all the languages supported
[Link] Framework. This means that the size of integer and long variables is same
across all .NET-compliant programming languages. However, each language uses
aliases for the base data types provided by CTS. For example, CTS uses the data type
system. int32 to represent a 4 byte integer value; however, Visual Basic uses the alias
integer for the same; whereas, C# uses the alias int. This is done for the sake of clarity
and simplicity.
3
11. Give a brief introduction on side-by-side execution. Can two applications,
one using private assembly and the other using the shared assembly be stated as
side-by-side executables?
CLR uses the Dispose and Finalize methods to perform garbage collection of run-
time objects of .NET applications.
The Finalize method is called automatically by the runtime. CLR has a garbage
collector (GC), which periodically checks for objects in heap that are no longer
referenced by any object or program. It calls the Finalize method to free the memory
used by such objects. The Dispose method is called by the [Link] is
another method to release the memory used by an object. The Dispose method needs
to be explicitly called in code to dereference an object from the heap.
The Dispose method can be invoked only by the classes that implement
the IDisposable interface.
Code access security (CAS) is part of the .NET security model that prevents
unauthorized access of resources and operations, and restricts the code to perform
particular tasks.
Managed code is the code that is executed directly by the CLR instead of the
operating system. The code compiler first compiles the managed code to intermediate
language (IL) code, also called as MSIL code. This code doesn't depend on machine
configurations and can be executed on different machines.
Unmanaged code is the code that is executed directly by the operating system outside
the CLR environment. It is directly compiled to native machine code which depends
on the machine configuration.
In the managed code, since the execution of the code is governed by CLR, the
runtime provides different services, such as garbage collection, type checking,
exception handling, and security support. These services help provide uniformity in
platform and language-independent behavior of managed code applications. In the
4
unmanaged code, the allocation of memory, type safety, and security is required to be
taken care of by the developer. If the unmanaged code is not properly handled, it may
result in memory leak. Examples of unmanaged code are ActiveX components and
Win32 APIs that execute beyond the scope of native CLR.
Tuple is a fixed-size collection that can have elements of either same or different data
types. Similar to arrays, a user must have to specify the size of a tuple at the time of
declaration. Tuples are allowed to hold up from 1 to 8 elements and if there are more
than 8 elements, then the 8th element can be defined as another tuple. Tuples can be
specified as parameter or return type of a method.
YOU can use the Code Access Security Tool ([Link]) to turn security on and off.
To turn off security, type the following command at the command prompt:
caspol -security off
In the .NET Framework 4.0, for using [Link], you first need to set
the <LegacyCasPolicy> element totrue.
GC has changed a bit with the introduction of .NET 4.0. In .NET 4.0,
the [Link]() method contains the following overloaded methods:
[Link](int)
[Link](int, GCCollectionMode)
5
a separate ephemeral GC - gen0 and gen1 can be started, while the full GC - gen0, 1,
and 2 - is already running.
There are two key concepts of CAS security policy- code groups and permissions. A
code group contains assemblies in it in a manner that each .NET assembly is related
to a particular code group and some permissions are granted to each code group. For
example, using the default security policy, a control downloaded from a Web site
belongs to the Zone, Internet code group, which adheres to the permissions defined
by the named permission set. (Normally, the named permission set represents a very
restrictive range of permissions.)
22. Is there a way to suppress the finalize process inside the garbage collector
forcibly in .NET?
Use the [Link]() method to suppress the finalize process inside the
garbage collector forcibly in .NET.
6
Using the new operator. For example,
Using the Create factory method available in the Tuple class. For example,
24. Which is the root namespace for fundamental types in .NET Framework?
The CAS mechanism in .NET is used to control and configure the ability of managed
code. Earlier, as this policy was applicable for only native applications, the security
guarantee was limited. Therefore, developers used to look for alternating solutions,
such as operating system-level solutions. This problem was solved in .NET
Framework 4 by turning off the machine-wide security. The shared and hosted Web
applications can now run more securely. The security policy in .NET Framework 4
has been simplified using the transparency model. This model allows you to run the
Web applications without concerning about the CAS policies.
As a result of security policy changes in .NET Framework 4.0, you may encounter
compilation warnings and runtime exceptions, if your try to use the obsolete CAS
policy types and members either implicitly or explicitly. However, you can avoid the
warnings and errors by using the <NetFx40_LegacySecurityPolicy>configuration
element in the runtime settings schema to opt into the obsolete CAS policy behavior.
The .NET Framework is shipped with compilers of all .NET programming languages
to develop programs. There are separate compilers for the Visual Basic, C#, and
Visual C++ programming languages in .NET Framework. Each .NET compiler
produces an intermediate code after compiling the source code. The intermediate code
is common for all languages and is understandable only to .NET environment. This
intermediate code is known as MSIL.
7
28. How many types of generations are there in a garbage collector?
Memory management in the CLR is divided into three generations that are build up
by grouping memory segments. Generations enhance the garbage collection
performance. The following are the three types of generations found in a garbage
collector:
In .NET 4.0, the CLR supports covariance and contravariance of types in generic
interfaces and delegates. Covariance enables you to cast a generic type to its base
types, that is, you can assign a instance of typeIEnumerable<Tl> to a variable of
type IEnumerable<T2> where, T1 derives from T2. For example,
.NET framework 4.0 uses some language keywords (out and in) to annotate
covariance and contra-variance. Out is used for covariance, while in is used for
contra-variance.
Variance can be applied only to reference types, generic interfaces, and generic
delegates. These cannot be applied to value types and generic types.
The following are the different ways to assign a value to a complex number:
By passing two Double values to its constructor. The first value represents the real,
and the second value represents imaginary part of a complex number.
For example,
8
Complex c1 = new Complex(5, 8); /* It represents (5, 8) */
By assigning a Byte, SByte, Intl6, UIntl6, Int32, UInt32, Int64, UInt64, Single,
or Double value to aComplex object. The assigned value represents the real part of
the complex number, and its imaginary part becomes 0. For example,
Complex c2 = 15.3; /* It represents (15.3, 0) */
CLS is a set of basic rules, which must be followed by each .NET language to be a
.NET- compliant language. It enables interoperability between two .NET-compliant
languages. CLS is a subset of CTS; therefore, the languages supported by CLS can
use each other's class libraries similar to their own. Application programming
interfaces (APIs), which are designed by following the rules defined in CLS can be
used by all .NET-compliant languages.
The JIT compiler is an important element of CLR, which loads MSIL on target
machines for execution. The MSIL is stored in .NET assemblies after the developer
has compiled the code written in any .NET-compliant programming language, such as
Visual Basic and C#.
JIT compiler translates the MSIL code of an assembly and uses the CPU architecture
of the target machine to execute a .NET application. It also stores the resulting native
code so that it is accessible for subsequent calls. If a code executing on a target
machine calls a non-native method, the JIT compiler converts the MSIL of that
method into native code. JIT compiler also enforces type-safety in runtime
environment of .NET Framework. It checks for the values that are passed to
parameters of any method.
For example, the JIT compiler detects any event, if a user tries to assign a 32-bit value
to a parameter that can only accept 8-bit value.
9
String and StringBuilder classes are used to store string values but the difference in
them is that String is immutable (read only) by nature, because a value once assigned
to a String object cannot be changed after its creation. When the value in the String
object is modified, a new object is created, in memory, with a new value assigned to
the String object. On the other hand, the StringBuilder class is mutable, as it occupies
the same space even if you change the value. The StringBuilder class is more efficient
where you have to perform a large amount of string manipulation.
There is no difference between int and int32. System.Int32 is a .NET Class and int is
an alias name forSystem.Int32.
2. What is a class?
10
A class describes all the attributes of objects, as well as the methods that implement
the behavior of member objects. It is a comprehensive data type, which represents a
blue print of objects. It is a template of object.
A class can be defined as the primary building block of OOP. It also serves as a
template that describes the properties, state, and behaviors common to a particular
group of objects.
A class contains data and behavior of an entity. For example, the aircraft class can
contain data, such as model number, category, and color and behavior, such as
duration of flight, speed, and number of passengers. A class inherits the data members
and behaviors of other classes by extending from them.
3. What is an object?
They are instance of classes. It is a basic unit of a system. An object is an entity that
has attributes, behavior, and identity. Attributes and behavior of an object are defined
by the class definition.
A class acts as a blue-print that defines the properties, states, and behaviors that are
common to a number of objects. An object is an instance of the class. For example,
you have a class called Vehicle and Car is the object of that class. You can create any
number of objects for the class named Vehicle, such as Van, Truck, and Auto.
The new operator is used to create an object of a class. When an object of a class is
instantiated, the system allocates memory for every data member that is present in the
class.
11
Array:
1. You need to specify the size of an array at the time of its declaration. It cannot
be resized dynamically.
2. The members of an array should be of the same data type.
Collection:
Class:
12
5. Class can contain constructor/destructor.
Structure:
Structures and classes are the two most important data structures that are used by
programmers to build modular programs by using OOP languages, such as Visual
Basic .NET, and Visual C#. The following are some of the similarities between a
class and a structure:
Access specifiers, such as public, private, and protected, are identically used
in structures and classes to restrict the access of their data and methods
outside their body.
The access level for class members and struct members, including nested
classes and structs, is private by default. Private nested types are not
accessible from outside the containing type.
Both can have constructors, methods, properties, fields, constants,
enumerations, events, and event handlers.
Both structures and classes can implement interfaces to use multiple-
inheritance in code.
Both structures and classes can have constructors with parameter.
Both structures and classes can have delegates and events.
Each delegate object holds reference to a single method. However, it is possible for a
delegate object to hold references of and invoke multiple methods. Such delegate
objects are called multicast delegates or combinable delegates.
16. Can you declare an overridden method to be static if the original method is
not static?
The virtual keyword is used while defining a class to specify that the methods and the
properties of that class can be overridden in derived classes.
13
18. Can you allow a class to be inherited, but prevent a method from being
overridden in C#?
Yes. Just declare the class public and make the method sealed.
Enumeration is defined as a value type that consists of a set of named values. These
values are constants and are called enumerators. An enumeration type is declared
using the enum keyword. Each enumerator in an enumeration is associated with an
underlying type that is set, by default, on the enumerator. The following is an
example that creates an enumeration to store different varieties of fruits:
Yes, you must handle exceptions in code so that you can deal with any unexpected
situations that occur when a program is running. For example, dividing a number by
zero or passing a string value to a variable that holds an integer value would result in
an exception.
No, you cannot inherit private members of a class because private members are
accessible only to that class and not outside that class.
14
24. Does .NET support multiple inheritance?
.NET does not support multiple inheritance directly because in .NET, a class cannot
inherit from more than one class. .NET supports multiple inheritance through
interfaces.
A delegate is similar to a class that is used for storing the reference to a method and
invoking that method at runtime, as required. A delegate can hold the reference of
only those methods whose signatures are same as that of the delegate. Some of the
examples of delegates are type-safe functions, pointers, or callbacks.
When a class is derived from another class, then the members of the base class
become the members of the derived class. The access modifier used while accessing
members of the base class specifies the access status of the base class members inside
the derived class.
An interface is a template that contains only the signature of methods. The signature
of a method consists of the numbers of parameters, the type of parameter (value,
reference, or output), and the order of parameters. An interface has no
implementation on its own because it contains only the definition of methods without
any method body. An interface is defined using the interface keyword. Moreover, you
cannot instantiate an interface. The various features of an interface are as follows:
15
An interface is used to implement multiple inheritance in code. This feature of
an interface is quite different from that of abstract classes because a class
cannot derive the features of more than one class but can easily implement
multiple interfaces.
It defines a specific set of methods and their arguments.
Variables in interface must be declared as public, static, and final while
methods must be publicand abstract.
A class implementing an interface must implement all of its methods.
An interface can derive from more than one interface.
No, the throws clause cannot be used to raise an exception. The throw statement
signals the occurrence of an exception during the execution of a program. When the
program encounters a throw statement, the method terminates and returns the error to
the calling method.
Methods are the building blocks of a class, in which they are linked together to share
and process data to produce the result. In other words, a method is a block of code
that contains a series of statements and represents the behavior of a class. While
declaring a method you need to specify the access specifier, the return value, the
name of the method, and the method parameters. All these combined together is
called the signature of the method.
The try block encloses those statements that can cause exception and the catch block
handles the exception, if it occurs. Catch block contains the statements that have to be
executed, when an exception occurs. Thefinally block always executes, irrespective
of the fact whether or not an exception has occurred. The finallyblock is generally
16
used to perform the cleanup process. If any exception occurs in the try block, the
program control directly transfers to its corresponding catch block and later to
the finally block. If no exception occurs inside the try block, then the program control
transfers directly to the finally block.
35. How can you prevent a class from overriding in C# and Visual Basic?
You can prevent a class from overriding in C# by using the sealed keyword; whereas,
the NotInheritablekeyword is used to prevent a class from overriding in Visual Basic.
36. What are abstract classes? What are the distinct characteristics of an
abstract class?
An abstract class is a class that cannot be instantiated and is always used as a base
class.
The following are the characteristics of an abstract class:
You cannot instantiate an abstract class directly. This implies that you cannot
create an object of the abstract class; it must be inherited.
You can have abstract as well as non-abstract members in an abstract class.
You must declare at least one abstract method in the abstract class.
An abstract class is always public.
An abstract class is declared using the abstract keyword.
The basic purpose of an abstract class is to provide a common definition of the base
class that multiple derived classes can share.
37. Give a brief description of properties in C# and the advantages that are
obtained by using them in programs.
Single inheritance - Contains one base class and one derived class
Hierarchical inheritance - Contains one base class and multiple derived
classes of the same base class
Multilevel inheritance - Contains a class derived from a derived class
Multiple inheritance - Contains several base classes and a derived class
17
All .NET languages supports single, hierarchical, and multilevel inheritance. They do
not support multiple inheritance because in these languages, a derived class cannot
have more than one base class. However, you can implement multiple inheritance
[Link] through interfaces.
39. You have defined a destructor in a class that you have developed by using the
C# programming language, but the destructor never executed. Why did the
destructor not execute?
The runtime environment automatically invokes the destructor of a class to release the
resources that are occupied by variables and methods of an object. However, in C#,
programmers cannot control the timing for invoking destructors, as Garbage Collector
is only responsible for releasing the resources used by an object. Garbage Collector
automatically gets information about unreferenced objects from .NET's runtime
environment and then invokes the Finalize() method.
You are allowed to include more than one catch block in your program; however, it is
not possible to execute them in one go. Whenever, an exception occurs in your
program, the correct catch block is e 43. What do you mean by data encapsulation?
Data encapsulation is a concept of binding data and code in single unit called object
and hiding all the implementation details of a class from the user. It prevents
unauthorized access of data and restricts the user to use the necessary data only.
Procedural programming is based upon the modular approach in which the larger
programs are broken into procedures. Each procedure is a set of instructions that are
18
executed one after another. On the other hand, OOP is based upon objects. An object
consists of various elements, such as methods and variables.
Access modifiers are not used in procedural programming, which implies that the
entire data can be accessed freely anywhere in the program. In OOP, you can specify
the scope of a particular data by using access modifiers -
public, private, internal, protected, and protected internal.
A destructor is used to free the dynamic allocated memory and release the resources.
You can, however, implement a custom method that allows you to control object
destruction by calling the destructor.
The classes in a namespace are internal, by default. However, you can explicitly
declare them as public only and not as private, protected, or protected internal. The
nested classes can be declared as private,protected, or protected internal.
Yes, it is true. Like classes, in C#, structures can implement one or more interfaces.
Static constructors are introduced with C# to initialize the static data of a class. CLR
calls the static constructor before the first instance is created.
19
49. What are the different ways a method can be overloaded?
Abstract Class:
Interface
Stacks refer to a list in which all items are accessed and processed on the Last-In-
First-Out (LIFO) basis. In a stack, elements are inserted (push operation) and deleted
(pop operation) from the same end called top.
Queues refer to a list in which insertion and deletion of an item is done on the First-
In-First-Out (FIFO) basis. The items in a queue are inserted from the one end, called
the rear end, and are deleted from the other end, called the front end of the queue.
20
Whenever an action takes place in a class, that class provides a notification to other
classes or objects that are assigned to perform particular tasks. These notifications are
called events. For example, when a button is clicked, the class generates an event
called Click. An event can be declared with the help of the event keyword.
struct emp
{
fixed int empID[15];
fixed char name[30];
fixed char addr[50];
fixed char dept[15];
fixed char desig[15];
}
The preceding example defines a structure emp and the members of this structure
specify the information of an employee.
We define abstract classes when we define a template that needs to be followed by all
the derived classes.
Contains a number of classes that provide you with various methods and
attributes to manage the communication between your application and data
source.
Enables you to access different data sources, such as Microsoft SQL Server,
and XML, as per your requirements.
Provides a rich set of features, such as connection and commands that can be
used to develop robust and highly efficient data services in .NET applications.
21
Provides various data providers that are specific to databases produced by
various vendors. For example, [Link] has a separate provider to access
data from Oracle databases; whereas, another provider is used to access data
from SQL databases.
The following are the benefits of using [Link] in .NET 4.0 are as follows:
22
supported by all the data providers; thereby, reducing the amount of coding
and maintenance in your application. In .NET Framework 4.0, many new
functions, such as string, aggregate, mathematical, and date/time functions
have been added.
The following namespaces are required to enable the use of databases in [Link]
pages:
23
13. Name the two properties of the GridView control that have to be specified to
turn on sorting and paging.
The properties of the GridView control that need to be specified to turn on sorting
and paging are as follows:
One of the major component of [Link] is the DataSet object, which always
remains disconnected from the database and reduces the load on the database.
The DataReader object helps in retrieving the data from a database in a forward-only,
read-only mode. The base class for all the DataReader objects is
the DbDataReader class.
24
An Open connection to read data from large tables consumes most of the system
resources. When multiple client applications simultaneously access a database by
using the DataReader object, the performance of data retrieval and other related
processes is substantially reduced. In such a case, the database might refuse
connections to other .NET applications until other clients free the resources.
18. How can you identify whether or not any changes are made to
the DataSet object since it was last loaded?
The DataSet object provides the following two methods to track down the changes:
If you want to revert all changes since the DataSet object was loaded, use
the RejectChanges() method.
20. Name the method that needs to be invoked on the DataAdapter control to fill
the generated DataSet with data?
The Connection object is used to connect your application to a specific data source by
providing the required authentication information in connection string. The
connection object is used according to the type of the data source. For example,
the OleDbConnection object is used with an OLE-DB provider and
the SqlConnectionobject is used with an MS SQL Server.
This class automatically registers itself as an event listener to the RowUpdating event.
Whenever data inside a row changes, the object of the CommandBuilder class
automatically generates an SQL statement and uses theSelectCommand property to
25
commit the changes made in DataSet.
The DataSet, which is disconnected from the data source and does not need to
know where the data that it holds is retrieved from.
The .net data provider, which allows you to connect your application to the
data source and execute the SQL commands against it.
The Command object in [Link] executes a command against the database and
retrieves a DataReader orDataSet object.
26
The ExecuteNonQuery() method executes a Transact-SQL statement
against the connection and returns the number of rows affected.
The ExecuteScalar() method returns a single value from a database
query.
The ExecuteReader() method returns a result set by using
the DataReader object.
There must be multiple processes to share the same connection describing the
same parameters and security settings.
The connection string must be identical.
You can enable or disable connection pooling in your application by setting the
pooling property to either true or false in connection string. By default, it is enabled
in an application.
28. What are the various methods provided by the DataSet object to generate
XML?
The various methods provided by the DataSet object to generate XML are:
The SQL Server Authentication technique is not trusted as all the values are verified
by SQL Server only.
27
30. How would you connect to a database by using .NET?
31. Which adapter should you use, if you want to get the data from an Access
database?
32. Which object is used to add a relationship between two DataTable objects?
The DataRelation object is used to add relationship between two DataTable objects.
33. What are different types of authentication techniques that are used in
connection strings to connect .NET applications with Microsoft SQL Server?
.NET applications can use two different techniques to authenticate and connect with
SQL Server. These techniques are as follows:
[Link] Entity Framework 4.0 is introduced in .NET Framework 4.0 and includes
the following new features:
Persistence Ignorance - Facilitates you to define your own Plain Old CLR
Objects (POCO) which are independent of any specific persistence
technology.
Deferred or Lazy Loading - Specifies that related entities can be loaded
automatically whenever required. You can enable lazy loading in your
application by setting the DeferredLoadingEnabledproperty to true.
Self-Tracking Entities - Refers to the entities that are able to track their own
changes. These changes can be passed across process boundaries and saved to
the database.
Model-First Development - Allows you to create your own EDM and then
generate relational model (database) from that EDM with matching tables and
relations.
Built-in Functions - Enables you to use built-in SQL Server functions
directly in your queries.
Model-Defined Functions - Enables you to use the functions that are defined
in conceptual schema definition language (CSDL).
35. What is the difference between the Clone() and Copy() methods of
the DataSet class?
28
The Clone() method copies only the structure of a DataSet. The copied structure
includes all the relation, constraint, and DataTable schemas used by the DataSet.
The Clone() method does not copy the data, which is stored in the DataSet.
The Copy() method copies the structure as well as the data stored in the DataSet.
37. What are the parameters that control most of connection pooling behaviors?
The parameters that control most of connection pooling behaviors are as follows:
Connect Timeout
Max Pool Size
Min Pool Size
Pooling
38. How can you add or remove rows from the DataTable object of DataSet?
The DataRowCollection class defines the collection of rows for the DataTable object
in a DataSet. TheDataTable class provides the NewRow() method to add a
new DataRow to DataTable. The NewRow method creates a new row, which
implements the same schema as applied to the DataTable. The following are the
methods provided by the DataRowCollection object:
The DataAdapter class retrieves data from the database, stores data in a dataset, and
reflects the changes made in the dataset to the database. The DataAdapter class acts
29
as an intermediary for all the communication between the database and
the DataSet object. The DataAdapter Class is used to fill
a DataTable or DataSetObject with data from the database using the Fill() method.
The DataAdapter class applies the changes made in dataset to the database by calling
the Update() method.
The DataAdapter class provides four properties that represent the database
command:
DLR is a runtime environment that allows you to integrate dynamic languages with
the Common Language Runtime (CLR) by adding a set of services, such as
expression trees, call site caching, and dynamic object interoperability to the CLR.
Binders are used by DLR to communicate with not the .NET Framework but also
with various other services, such as Silverlight and COM. These services represent
language-specific semantics and specify how a particular operation can be performed
at the call site.
Call sites refer to the area in the code where logical and mathematical operations,
such as a + b or a.b() are performed on dynamic objects.
30
4. Explain the different services provided by DLR to CLR.
The services provided by DLR to CLR are used for supporting dynamic languages.
These services include the following:
The ExpandoObject class refers to a class whose members can be explicitly added
and removed at runtime. In other words, the ExpandoObject class allows dynamic
binding of the objects, which enables you to use standard syntax, similar to
the [Link] method instead of using more complex syntax, such
[Link]("Method").
The DynamicObject class enables you to define the dynamic behavior for an object at
run time. This class cannot be instantiated directly; therefore, to implement the
dynamic behavior, you must inherit from theDynamicObject class and override the
necessary methods. It allows you to define the specific operations that can be
performed on dynamic objects as well the methods to perform those operations.
31
7. What is the difference between dynamic and var data types?
The difference between the var and dynamic data types is that the var data type is
strongly type checked at the compile time; whereas, the dynamic data type is type
checked by the compiler only at run time. After declaring a var data type, you cannot
explicitly change its type throughout the execution of the program; however, a
variable of the dynamic data type can be changed during runtime. Another major
difference between the two is that dynamic type can also be used as the return type
for methods, for which var cannot be used.
The [Link] class provides a complete set of methods for converting the data
types.
1. What is ASP?
Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side
technology, which helps in creating dynamic and user-friendly Web pages. It uses
different scripting languages to create dynamic Web pages, which can be run on any
type of browser. The Web pages are built by using either VBScript or JavaScript and
these Web pages have access to the same services as Windows application, including
ADO (ActiveX Data Objects) for database access, SMTP (Simple Mail Transfer
Protocol) for e-mail, and the entire COM (Component Object Model) structure used
in the Windows environment. ASP is implemented through a dynamic-link library
([Link]) that is called by the IIS server when a Web page is requested from the server.
2. What is [Link]?
The basic difference between ASP and [Link] is that ASP is interpreted; whereas,
[Link] is compiled. This implies that since ASP uses VBScript; therefore, when
an ASP page is executed, it is interpreted. On the other hand, [Link] uses .NET
languages, such as C# and [Link], which are compiled to Microsoft Intermediate
Language (MSIL).
32
4. In which event are the controls fully loaded?
Page load event guarantees that all controls are fully loaded. Controls are also
accessed in Page_Init events but you will see that view state is not fully loaded during
this event
Page object has an "IsPostBack" property, which can be checked to know that is the
page posted back.
The items stored in ViewState live until the lifetime of the current page expires
including the postbacks to the same page.
The SQL cache notification generates notifications when the data of a database
changes, on which your cache item depends. The SQL cache invalidation makes a
cached item invalid when the data stored in a SQL server database changes.
The [Link] class is the parent class for all Web server controls.
10. Can you set which type of comparison you want to perform by
the CompareValidator control?
11. What is the behavior of a Web browser when it receives an invalid element?
The behavior of a Web browser when it receives an invalid element depends on the
browser that you use to browse your application. Most of the browsers ignore the
invalid element; whereas, some of them display the invalid elements on the page.
33
Provides the isolation of effort between graphic designers and software
engineers
Removes the problems of browser incompatibility by providing code files to
exist on the Web server and supporting Web pages to be compiled on demand.
13. How do you sign out from forms authentication?
The [Link]() method is used to sign out from the forms
authentication.
14. What is AutoPostBack?
If you want a control to postback automatically when an event is raised, you
need to set the AutoPostBackproperty of the control to True.
15. What is the function of the ViewState property?
The [Link] 4.0 introduced a new property called ViewStateMode for
the Control class. Now you can enable the view state to an individual control
even if the view state for an [Link] page is disabled.
16. Why do you use the App_Code folder in [Link]?
The App_Code folder is automatically present in the project. It stores the files,
such as classes, typed data set, text files, and reports. If this folder is not
available in the application, you can add this folder. One of the important
features of the App_Code folder is that only one dll is created for the complete
folder, irrespective of how many files it contains.
17. Define a multilingual Web site.
A multilingual Web site serves content in a number of languages. It contains
multiple copies for its content and other resources, such as date and time, in
different languages.
18. What is an [Link] Web Form?
[Link] Web forms are designed to use controls and features that are almost
as powerful as the ones used with Windows forms, and so they are called as
Web forms. The Web form uses a server-side object model that allows you to
create functional controls, which are executed on the server and are rendered
as HTML on the client. The attribute, runat="server", associated with a server
control indicates that the Web form must be processed on the server.
19. What is the difference between a default skin and a named skin?
The default skin is applied to all the Web server controls in a Web form, which are of
similar type, and it does not provide a Skin ID attribute. The named skin provides a
Skin ID attribute and users have to set the Skin ID property to apply it.
34
21. What is Query String? What are its advantages and limitations?
The Query String helps in sending the page information to the server.
Information must be within the limit because URL does not support many
characters.
Information is clearly visible to the user, which leads to security threats.
22. What is actually returned from server to the browser when a browser
requests an .aspx file and the file is displayed?
When a browser requests an .aspx file then the server returns a response, which is
rendered into a HTML string.
23. How can you display all validation messages in one control?
24. Which two new properties are added in [Link] 4.0 Page class?
Tracing displays the details about how the code was executed. It refers to collecting
information about the application while it is running. Tracing information can help
you to troubleshoot an application. It enables you to record information in various log
files about the errors that might occur at run time. You can analyze these log files to
find the cause of the errors.
In .NET, we have objects called Trace Listeners. A listener is an object that gets the
trace output and stores it to different places, such as a window, a file on your locale
drive, or a SQL Server.
35
26. What is the difference between authentication and authorization?
Authentication verifies the identity of a user and authorization is a process where you
can check whether or not the identity has access rights to the system. In other words,
you can say that authentication is a procedure of getting some credentials from the
users and verify the user's identity against those credentials. Authorization is a
procedure of granting access of particular resources to an authenticated user. You
should note that authentication always takes place before authorization.
27. How can you register a custom server control to a Web page?
28. Which [Link] objects encapsulate the state of the client and the browser?
The Session object encapsulates the state of the client and browser.
The globalization is a technique to identify the specific part of a Web application that
is different for different languages and make separate that portion from the core of the
Web application. The localization is a procedure of configuring a Web application to
be supported for a specific language or locale.
The ViewState is a feature used by [Link] Web page to store the value of a page
and its controls just before posting the page. Once the page is posted, the first task by
the page processing is to restore the ViewState to get the values of the controls.
31. Which method is used to force all the validation controls to run?
The [Link]() method is used to force all the validation controls to run and to
perform validation.
32. Which method has been introduced in [Link] 4.0 to redirect a page
permanently?
RedirectPermanent("/path/[Link]");
33. How can you send an email message from an [Link] Web page?
36
You can use the [Link] and
the [Link] classes to send an email in your Web pages. In order
to send an email through your mail server, you need to create an object of
the SmtpClient class and set the server name, port, and credentials.
The [Link]() method allows you to write the normal output; whereas,
[Link]() method allows you to write the formatted output.
Orientation property of the Menu control sets the horizontal or vertical display of a
menu on a Web page. By default, the orientation is vertical.
Client-side validations take place at the client end with the help of JavaScript and
VBScript before the Web page is sent to the server. On the other hand, server-side
validations take place at the server end.
A content page does not have complete HTML source code; whereas a master page
has complete HTML source code inside its source file.
38. Suppose you want an [Link] function (client side) executed on the
MouseOver event of a button. Where do you add an event handler?
The event handler is added to the Add() method of the Attributes property.
HTTP handlers, as the name suggests, are used to handle user requests for Web
application resources. They are the backbone of the request-response model of Web
applications. There is a specific event handler to handle the request for each user
request type and send back the corresponding response object.
Each user requests to the IIS Web server flows through the HTTP pipeline, which
refers to a series of components (HTTP modules and HTTP handlers) to process the
request. HTTP modules act as filters to process the request as it passes through the
HTTP pipeline. The request, after passing through the HTTP modules, is assigned to
an HTTP handler that determines the response of the server to the user request. The
37
response then passes through the HTTP modules once again and is then sent back to
the user.
You can define HTTP handlers in the <httpHandlers> element of a configuration file.
The <add> element tag is used to add new handlers and the <remove> element tag is
used to remove existing handlers. To create an HTTP handler, you need to define a
class that implements the IHttpHandler interface.
41. What are the events that happen when a client requests an [Link] page
from IIS server?
The following events happen when a client requests an [Link] page from the IIS
server:
In file-based dependency, you have to depend on a file that is saved in a disk. In key-
based dependency, you have to depend on another cached item.
43. How can you implement the postback property of an [Link] control?
The server tells the browser to put some files in a cookie, and the client then sends all
the cookies for the domain in each request. An example of cookie abuse is large
cookies affecting the network traffic.
Login controls are built-in controls in [Link] for providing a login solution to
[Link] application. The login controls use the membership system to authenticate
a user credentials for a Web site.
38
Login control - Provides an interface for user authentication. It consists of a
set of controls, such asTextBox, Label, Button, CheckBox, HyperLink.
LoginView control - Displays appropriate information to different users
according to the user's status.
LoginStatus control - Shows a login link to users, who are not authenticated
and logout link, who are authenticated
LoginName control - Displays a user name, if the user logs in.
PasswordRecovery control - Allows users to get back the password through an
e-mail, if they forget.
The PlaceHolder control acts as a container for those controls that are dynamically
generated at runtime. We cannot see it at runtime because it does not produce any
visible output. It used only as a container.
47. What setting must be added in the configuration file to deny a particular
user from accessing the secured resources?
To deny a particular user form accessing the secured resources, the [Link] file
must contain the following code:
<authorization >
<deny users="username" />
</authorization>
48. What are the event handlers that can be included in the [Link] file?
The [Link] file contains some of the following important event handlers:
Application_Error
Application_Start
Application_End
Session_Start
Session_End
49. What is the difference between page-level caching and fragment caching?
In the page-level caching, an entire Web page is cached; whereas, in the fragment
caching, a part of the Web page, such as a user control added to the Web page, is
cached.
ItemTemplate
AlternatingltemTemplate
39
SeparatorTemplate
HeaderTemplate
FooterTemplate
When we execute a Web page, it passes from the following stages, which are
collectively known as Web page lifecycle:
Page request - During this stage, [Link] makes sure the page either parsed
or compiled and a cached version of the page can be sent in response
Start - During this stage sets the Request and Response page properties and
the page check the page request is either a postback or a new request
Page Initialization - During this stage, the page initialize and the control's
Unique Id property are set
Load - During this stage, if the request is postback, the control properties are
loaded without loading the view state and control state otherwise loads the
view state
Validation - During this stage, the controls are validated
Postback event handling - During this stage, if the request is a postback,
handles the event
Rendering - During this stage, the page invokes the Render method to each
control for return the output
Unload - During this stage, when the page is completely rendered and sent to
the client, the page is unloaded.
52. How can you assign page specific attributes in an [Link] application?
53. Which method is used to post a Web page to another Web page?
The [Link] method is used to post a page to another page, as shown in the
following code snippet: [Link]("[Link]");
The custom user controls are the controls that are defined by developers. These
controls are a mixture of custom behavior and predefined behavior. These controls
work similar to other Web server controls.
40
56. What does the .WebPart file do?
The .WebPart file explains the settings of a Web Parts control that can be included to
a specified zone on a Web page.
The Page object uses the IsPostBack property to check whether the page is posted
back or not. If the page is postback, this property is set to true.
60. What is State Management? How many ways are there to maintain a state in
.NET?
There are two ways to maintain a state in .NET, Client-Based state management and
Server-Based state management.
View State
Hidden Fields
Cookies
Query Strings
Control State
Application State
Session State
Profile Properties
41
Aggregate dependency allows multiple dependencies to be aggregated for content that
depends on more than one resource. In such type of dependency, you need to depend
on the sum of all the defined dependencies to remove a data item from the cache.
62. How can you ensure that no one has tampered with ViewState in a Web
page?
To ensure that no one has tampered with ViewState in a Web page, set
the EnableViewStateMac property to True.
63. What is the difference between adding items into cache through
the Add() method and through theInsert() method?
Both methods work in a similar way except that the [Link]() function returns an
object that represents the item you added in the cache. The [Link]() function
can replace an existing item in the cache, which is not possible using
the [Link]() method.
[Link] manages the session state in the same process that processes the request
and does not create a cookie. It is known as a cookie less session. If cookies are not
available, a session is tracked by adding a session identifier to the URL. The cookie
less session is enabled using the following code snippet:<sessionState
cookieless="true" />
The trip of a Web page from the client to the server and then back to the client is
known as a round trip.
Application
Request
Response
Server
Session
Context
Trace
67. Where should the data validations be performed-at the client side or
at the server side and why?
Data validations should be done primarily at the client side and the server-side
validation should be avoided because it makes server task overloaded. If the
client-side validation is not available, you can use server-side validation.
42
When a user sends a request to the server, the validation controls are invoked
to check the user input one by one.
68. Why do we need nested master pages in a Web site?
When we have several hierarchical levels in a Web site, then we use nested
master pages in the Web site.
69. How can you dynamically add user controls to a page?
User controls can be dynamically loaded by adding a Web User Control page
in the application and adding the control on this page.
70. What is the appSettings Section in the [Link] file?
The [Link] file sets the configuration for a Web project.
The appSettings block in configuration file sets the user-defined values for the
whole application.
<configuration>
<appSettings>
<add key="ConnectionString" value="server=indiabixserver;
pwd=dbpassword; database=indiabix" />
</appSettings>
...
71. What type of code, client-side or server-side, is found in a code-behind
file of a Web page?
A code-behind file contains the server-side code, which means that the code
contained in a code-behind file is executed at the server.
72. To which class a Web form belongs to in the .NET Framework class
hierarchy?
A Web form belongs to the [Link] class.
73. What does the "EnableViewState" property do? Why do we want it
On or Off?
The EnableViewState property enables the ViewState property on the page. It
is set to On to allow the page to save the users input between postback
requests of a Web page; that is, between the Request and
corresponding Response objects. When this property is set to Off, the page
does not store the users input during postback.
74. Which event determines that all the controls are completely loaded
into memory?
The Page_Load event determines that all the controls on the page are fully
loaded. You can also access the controls in the Page_Init event; however,
the ViewState property does not load completely during this event.
75. What is the function of the CustomValidator control?
It provides the customize validation code to perform both client-side and
server-side validation.
76. What is Role-based security?
In the Role-based security, you can assign a role to every user and grant the
privilege according to that role. A role is a group of principal that restricts a
43
user's privileges. Therefore, all the organization and applications use role-
based security model to determine whether a user has enough privileges to
perform a requested task.
77. Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double,
String, Currency, and Date.
78. What are the HTML server controls in [Link]?
HTML server controls are similar to the standard HTML elements, which are
normally used in HTML pages. They expose properties and events that can be
used programmatically. To make these controls programmatically accessible,
you need to specify that the HTML controls act as a server control by adding
the runat="server"attribute.
79. Why a SiteMapPath control is referred to as breadcrumb or eyebrow
navigation control?
The SiteMapPath control displays a hierarchical path to the root Web page of
the Web site. Therefore, it is known as the breadcrumb or eyebrow navigation
control.
80. Where is the ViewState information stored?
The ViewState information is stored in the HTML hidden fields.
81. Which namespaces are necessary to create a localized application?
The [Link] and [Link] namespaces are essential to
develop a localized application.
82. What is the difference between an HtmlInputCheckBox control and
an HtmlInputRadioButton control?
You can select more than one HtmlInputCheckBox control from a group
of HtmlInputCheckBox controls; whereas, you can select only a
single HtmllnputRadioButton control from a group
ofHtmlInputRadioButton controls.
83. What is the difference between HTML and Web server controls?
HTML controls are client-side controls; therefore, all the validations for
HTML controls are performed at the client side. On the other hand, Web
server controls are server-side controls; therefore, all the validations for Web
server controls are performed at the server side.
84. Explain the AdRotator Control.
The AdRotator is an [Link] control that is used to provide advertisements
to Web pages. The AdRotatorcontrol associates with one or many
advertisements, which randomly displays one by one at a time when the Web
page is refreshed. The AdRotator control advertisements are associated with
links; therefore, when you click on an advertisement, it redirects you to other
pages.
44
The culture denotes a combination of a language and optionally a region or a country.
The contents of a Web page of a multilingual Web site are changed according to the
culture defined in the operating system of the user accessing the Web page.
The absolute expiration expires a cached item after the provided expiration time. The
sliding time does not expire the cached items because it increments the specified time.
The code-behind feature of [Link] enables you to divide an [Link] page into
two files - one consisting of the presentation data, and the second, which is also called
the code-behind file, consisting of all the business logic. The presentation data
contains the interface elements, such as HTML controls and Web server controls, and
the code-behind contains the event-handling process to handle the events that are
fired by these controls. The file that contains the presentation data has the .aspx
extension. The code behind file has either the .cs extension (if you are using the
programming language C#) or the .vb (if you are using the programming language
Visual Basic .NET) extension.
88. How can you check if all the validation controls on a Web page are valid and
proper?
You can determine that all the validation controls on a Web page are properly
working by writing code in the source file of the Web page using a scripting
language, such as VBScript or JavaScript. To do this task, you have to loop across
validators collection of pages and check the IsValid property of each validation
control on the Web page to check whether or not the validation test is successful.
89. Explain the validation controls. How many validation controls in [Link]
4.0?
Validation controls are responsible to validate the data of an input control. Whenever
you provide any input to an application, it performs the validation and displays an
error message to user, in case the validation fails.
45
ValidationSummary - Displays a summary of all validation error in a central
location.
The Label control's final html code has an HTML tag; whereas, the Literal control's
final html code contains only text, which is not surrounded by any HTML tag.
Session Cookie - Resides on the client machine for a single session until the
user does not log out.
Persistent Cookie - Resides on a user's machine for a period specified for its
expiry, such as 10 days, one month, and never.
The Culture value determines the functions, such as Date and Currency, which are
used to format data and numbers in a Web page. The UICulture value determines the
resources, such as strings or images, which are loaded for a Web page in a Web
application.
94. What is the difference between ASP session and [Link] session?
ASP does not support cookie-less sessions; whereas, [Link] does. In addition, the
[Link] session can span across multiple servers.
95. Which control will you use to ensure that the values in two different controls
match?
You should use the CompareValidator control to ensure that the values in two
different controls match.
96. What is the difference between a page theme and a global theme?
A page theme is stored inside a subfolder of the App_Themes folder of a project and
applied to individual Web pages of that project. Global themes are stored inside the
46
Themes folder on a Web server and apply to all the Web applications on the Web
server.
When you specify a language but do not specify the associated country through a
culture, the culture is called as a neutral culture.
98. What is the use of the <sessionState> tag in the [Link] file?
The <sessionState> tag is used to configure the session state features. To change the
default timeout, which is 20 minutes, you have to add the following code snippet to
the [Link] file of an application:<sessionState timeout="40"/>
99. Can you post and access view state in another application?
Yes, you can post and access a view state in other applications. However, while
posting a view state in another application, the PreviousPage property returns null.
47
Text - Displays a text for validation control before validation
104. What are navigation controls? How many navigation controls are there in
[Link] 4.0?
Navigation controls help you to navigate in a Web application easily. These controls
store all the links in a hierarchical or drop-down structure; thereby facilitating easy
navigation in a Web application.
SiteMapPath
Menu
TreeView
The server-side comments begin with <%-- and end with --%>.
107. How can we provide the WebParts control functionality to a server control?
108. How do you prevent a validation control from validating data at the client
end?
You can prohibit a validation control to validate data at the client side by setting
the EnableClientScriptproperty to False.
The [Link]() method is used to post data from one page to another. In this
case, the URL remains the same. However, in cross page posting, data is collected
from different Web pages and is displayed on a single page. To do so, you need to set
the PostBackUrl property of the control, which specifies the target page. In the target
page, you can access the PreviousPage property. For this, you need to use
48
the@PreviousPageType directive. You can access the controls of previous page by
using the FindControl()method.
There are many [Link] configuration choices, which are not able to configure at
the site, application, or child directory level on the shared hosting environment. Some
options can produce security, performance, and stability problem to the server and
therefore cannot be changed.
The following settings are the only ones that can be changed in the [Link] file(s)
of your Web site:
browserCaps
clientTarget
pages
customErrors
globalization
authorization
authentication
webControls
webServices
Each client accessing a Web application maintains a distinct session with the Web
server, and there is also some specific information associated with each of these
sessions. Session state is defined in the<sessionState> element of the [Link] file.
It also stores the data specific to a user session in session variables. Different session
variables are created for each user session. In addition, session variables can be
accessed from any page of the application. When a user accesses a page, a session ID
for the user is created. The session ID is transferred between the server and the client
over the HTTP protocol using cookies.
112. How will you differentiate a submaster page from a top-level master page?
49
Similar to a content page, a submaster page also does not have complete HTML
source code; whereas, a top-level master page has complete HTML source code
inside its source file.
The [Link] Web server controls are objects on the [Link] pages that run when
the Web page is requested. Many Web server controls, such as button and text box,
are similar to the HTML controls. In addition to the HTML controls, there are many
controls, which include complex behavior, such as the controls used to connect to
data sources and display data.
A HyperLink control does not have the Click and Command events; whereas,
the LinkButton control has these events, which can be handled in the code-behind file
of the Web page.
There are various techniques in [Link] to authenticate a user. You can use one of
the following ways of authentication to select a built-in authentication provider:
116. What are the different ways to send data across pages in [Link]?
The following two ways are used to send data across pages in [Link]:
Session
Public properties
The WebpartListUserControlPath property sets the route of the user defined control
to aDeclarativeCatalogPart control.
50
118. What do you mean by the Web Part controls in [Link]?
The Web Part controls are the integrated controls, which are used to create a Web
site. These controls allow the users to change the content, outlook, and state of Web
pages in a Web browser.
119. What type of the CatalogPart control enables users to restore the Web Parts
that have been removed earlier by the user?
[Link] configuration files are XML-based text files for application-level settings
and are saved with the name [Link]. These files are present in multiple
directories on an [Link] Web application server. [Link] file sets the
configuration settings to the directory it is placed in and to all the virtual sub folders
under it. The settings in sub directories can optionally override or change the settings
specified in the base directory.
The difference between the [Link] and [Link] files is given as follows:
<WinDir>\[Link]\Framework\<version>\config\[Link] provi
des default configuration settings for the entire machine. [Link] configures
IIS to prohibit the browser directly from accessing the [Link] files to
make sure that their values cannot be public. Attempts to access those files
cause [Link] to return the 403: Access Forbidden error.
[Link] uses these [Link] configuration files at runtime to compute
hierarchically a sole collection of settings for every URL target request. These
settings compute only once and cached across further requests. [Link]
automatically checks for changing file settings and do not validate the cache if
any of the configuration changes made.
If you are not using states, these changes are discarded and are not saved. You may
think that the whole concept of storing states is optional. However, under certain
circumstances, using states with applications is imperative. For example, it is
necessary to store states for Web applications, such as an e-commerce shopping site
51
or an Intranet site of a company, to keep track of the requests of the users for the
items they have selected on the shopping site or the days requested for vacation on
the Intranet site.
3. What is a workflow?
52
A workflow is a collection of actions (called activities) that presents the model of a
process. A workflow provides a way to describe the order of the execution of a long
running process and relationships between different activities. Multiple instances of a
workflow may be active at any given moment in an application.
According to Microsoft, there are four major principles that explain the behavior and
working of workflows. Developers can use these principles while developing
workflow-based applications. The four principles are as follows:
53
8. Can you integrate workflow applications with some other application, such as
Windows Forms applications and Web applications?
Yes.
11. What is the function of the Rule Condition Editor dialog box in WF?
You can create and modify declarative rule conditions by using the Rule Condition
Editor dialog box.
None - Represents a bookmark that can be resumed exactly once. This is the
default bookmark type.
MultipleResume - Refers to a bookmark that you can resume multiple times.
NonBlocking - Refers to a bookmark that does not block the functioning of
the workflow.
54
Web services in the host process or remoting to enable other applications to
communicate with the workflow.
Runtime services consist of predefined and user-defined classes that are available to
the workflow runtime engine during execution to customize the behavior of workflow
runtime. Some of the runtime services available in WF 4.0 are as follows:
16. Which option do you need to select for the Condition property, if you want to
create a code condition?
You can select the Code Condition option to create a code condition.
In addition to the standard activities available within the base activity library, you can
create new activities to meet specific business needs. Creating custom activities may
be required to support a particular application that you want to integrate with WF.
Custom activities are generally created through attributes and inheritance. You can
create two types of custom activities, base and composite. You can create basic
custom activity by inheriting the Activity class and custom composite activity by
inheriting the compositeActivity class or a derived type.
55
Dynamic update is a powerful feature of WF that describes the ability of WF to
modify the execution path of a running workflow. This feature is used in
circumstances that call for extraneous behavior that was not modeled by the original
workflow developer.
A runtime engine of WF provides the basic functionality to execute and manage the
workflow lifetime. It runs within the host process and is responsible for executing
each workflow instance. A host process can interact with multiple runtime engines at
a time, where each engine executes multiple workflow instances. The host process
interacts with runtime engine by using any of the following classes:
Workflows serve the purpose of automating business processes. Now, since each type
of business has a wide range of problems; therefore, a workflow platform needs to be
extensible. WF provides you with a set of base activities, such as IfElse, Code, and
Delay, to build a workflow. You can extend these activities or build new activities to
meet your requirements. Besides activities, you can also extend services, such as
tracking, management, and persistence, provided by the runtime engine.
22. Write the steps that are involved in the sequential workflow, by default.
Start
Finish
1. What is deployment?
56
Deployment refers to the distribution of an application among various end-users. It is
a process that makes software available for use by just installing it on the client
computer.
2. List different ways of deployment that are supported by .NET Framework 4.0.
Windows Installer
ClickOnce
XCOPY
Copy Web Site
Publish Web Site tool
3. What is XCOPY?
No. By default, XCOPY excludes the hidden and system files. However, you can
include the hidden and system files using the /h switch.
The end-users can then run the installer package to install the application anywhere in
their computers. The installation takes place using the installation wizard; therefore,
the users can easily install the application on their system. Once your application is
installed on the target computer, end-users can open the application from the installed
location.
6. Can you deploy an [Link] Web application project using the Copy Web
Site option?
No. The Copy Web Site option can only be used to deploy the Web sites.
7. How can you determine whether you should deploy the application or publish
the application?
57
If you want to host the application on a shared hosting environment, you should use
publishing; whereas, if you want to create a Web application that is downloaded from
a Web site, you should deploy the application to create a [Link] file.
You can deploy an [Link] Web application using either the Windows Installer
deployment or ClickOnce deployment technique.
In .NET 4.0, the ClickOnce deployment technology is enhanced with the following
features:
In deployment, you can create a new setup and deployment project. In this project,
you can add the project output and create a [Link] file. After creating an
executable file, you need to login into the server and execute the [Link] file to
install the application. On the other hand, in publishing, you need to right-click the
application in the Solution Explorer and select Publish to publish the application.
Then, you specify a location where the application is to be published. The users can
58
then install the application from the location where you have published it and run
locally even when the computer is offline.
Merge Module projects are used to package the files and components that are shared
between multiple applications. The Merge Module project file contains
the .msm extension. The .msm file includes files, resources, registry entries, and setup
logic. This file is merged with a Windows installer (.msi) file to correctly install the
shared files. If a single merge module is used by more than one application, then you
need to add that merge module in the package only once.
Copy Web Site is a tool used to deploy the Web site by copying its content files. The
Copy Web Site tool also checks whether or not the latest version of a file is present at
the destination. If files of the most recent version are found at the destination, then the
Copy Web Site tool does not superimpose the older version of files. The Copy Web
Site deployment tool consists of the following main entities:
Project source - Specifies the source directory, which contains the contents
and references of a Web site at development time. In simple words, you can
say that the project source specifies the site that you currently have opened in
Visual Studio 2010. The Copy Web Site tool picks all the files for deployment
from this location.
Project destination - Specifies the destination folder where you have to
deploy the application. This destination directory can be placed on remote
computers or servers, which allow you to copy the Web site contents using the
Front Page Server Extensions, FTP, or HTTP protocol implementations for
content transfer.
Synchronizing two Web sites - Synchronizes two Web sites by copying each
other's files. Synchronization checks the files on the local and remote sites and
ensures that all files on both sites are up to date.
The Copy Project command copies only the files required to run the project and
pastes it on the target server. It does not deploy the complete project; therefore, IIS
directory settings are not automatically configured.
15. Can Windows applications and the Web applications be deployed using the
same template of Setup and Deployment project?
No. the Windows applications use the Setup Project template; whereas, the Web
applications use the Web Setup Project template. After the deployment, their
installation takes place in the similar way.
59
In a general context, .NET Framework includes the following deployment features:
The cloud computing is the computing which is completely based on the Internet. It
can also be defined as the next stage in the evolution of the Internet. The cloud
computing uses the cloud (Internet) that provides the way to deliver the services
whenever and wherever the user of the cloud needs. Companies use the cloud
computing to fulfill the needs of their customers, partners, and providers. The cloud
computing includes vendors, partners, and business leaders as the three major
contributors. The vendors are the one who provide applications and their related
technology, infrastructure, hardware, and integration.
The partners are those who offer cloud services demand and provide support service
to the customers. The business leaders are the ones who use or evaluate the cloud
service provided by the partners. The cloud computing enables the companies to treat
their resources as a pool and not as independent resources.
2. What is a cloud?
60
3. What are the basic characteristics of cloud computing?
A cloud service is a service that is used to build cloud applications. This service
provides the facility of using the cloud application without installing it on the
computer. It reduces the maintenance and support of the application as compared to
those applications that are not developed using the cloud service. The different kinds
of users can use the application from the cloud service, which may be public or
private application.
1. Public cloud
2. Private cloud
3. Community cloud
4. Hybrid cloud
The AppFabric component is used to create access control and distribute messages
across clouds and enterprises. It has a service-oriented architecture, and can be
considered as the backbone of the Windows Azure platform. It provides connectivity
and messaging among distributed applications. It also has the capabilities of
integrating the applications and the business processes between cloud services and
also between cloud services and global applications.
61
with Visual Studio [Link] Communication Foundation
(WCF) services built in VS 2010 can be published on cloud from the Visual Studio
design environment.
The workload can be defined as an independent service or a set of code that can be
executed. It can be everything from a data-intensive workload to storage or a
transaction processing workload and does not rely upon the outside elements. The
workload can be considered as a small or complete application.
Windows Azure provides three core services which are given as follows:
Compute
Storage
Management
62
The hybrid cloud consists of multiple service providers. This model integrates
various cloud services for Hybrid Web hosting. It is basically a combination of
private and public cloud features. It is used by the company when a company has
requirements for both the private and public clouds. Consider an example when an
organization wants to implement the SaaS (Software as a Service) application
throughout the company. The implementation requires security that can be provided
by the private cloud used inside the firewall. The additional security can be provided
by the VPN on requirement. Now, the organization has both the private and public
cloud features.
The community cloud provides a number of benefits, such as privacy and security.
This model, which is quite expensive, is used when the organizations having common
goals and requirements are ready to share the benefits of the cloud service.
The public cloud (or external cloud) is freely available for access. You can use a
public cloud to collect data of the purchasing of items from a Web site on the
Internet. You can also use public cloud for the reasons, which are given as follows:
The private cloud allows the usage of services by a single client on a private
network. The benefits of this model are data security, corporate governance, and
reliability concerns. The private cloud is used by the organization when it has a huge,
well-run data center having a lot of spare capacity. It is also used when an
organization is providing IT services to its clients and the data of organization is
highly important. It is best suited when the requirements are critical.
63
The Windows Azure operating system is used for running cloud services on the
Windows Azure platform, as it includes necessary features for hosting your services
in the cloud. It also provides runtime environment that consists of Web server,
computational services, basic storage, queues, management services, and load
balancers. The operating system provides development. Fabric for development and
testing of services before their deployment on the Windows Azure in the cloud.
<Data_type> <variable_name> ;
A constant is similar to a variable except that the value, which you assign to a
constant, cannot be changed, as in case of a variable. Constants must be initialized at
the same time they are declared. You can declare constants by using the following
syntax:
2. What is a data type? How many types of data types are there in .NET ?
A data type is a data storage format that can contain a specific type or range of values.
Whenever you declare variables, each variable must be assigned a specific data type.
Some common data types include integers, floating point, characters, and strings. The
following are the two types of data types available in .NET:
Value type - Refers to the data type that contains the data. In other words, the
exact value or the data is directly stored in this data type. It means that when
you assign a value type variable to another variable, then it copies the value
rather than copying the reference of that variable. When you create a value
64
type variable, a single space in memory is allocated to store the value (stack
memory). Primitive data types, such as int, float, and char are examples of
value type variables.
Reference type - Refers to a data type that can access data by reference.
Reference is a value or an address that accesses a particular data by address,
which is stored elsewhere in memory (heap memory). You can say that
reference is the physical address of data, where the data is stored in memory
or in the storage device. Some built-in reference types variables in .Net are
string, array, and object.
3. Mention the two major categories that distinctly classify the variables of C#
programs.
Variables that are defined in a C# program belong to two major categories: value
type and reference type. The variables that are based on value type contain a value
that is either allocated on a stack or allocated in-line in a structure. The variables that
are based on reference types store the memory address of a variable, which in turn
stores the value and are allocated on the heap. The variables that are based on value
types have their own copy of data and therefore operations done on one variable do
not affect other variables. The reference-type variables reflect the changes made in
the referring variables.
int x = 42;
int y = 12;
int w;
object o;
o = x;
w = y * (int)o;
[Link](w);
65
The syntax for declaring a namespace in VB is:
Namespace UserNameSpace
6. What is the difference between constants and read-only variables that are
used in programs?
Constants perform the same tasks as read-only variables with some differences. The
differences between constants and read-only are
Constants:
Read-only:
The while and for loops are used to execute those units of code that need to be
repeatedly executed, unless the result of the specified condition evaluates to false.
The only difference between the two is in their syntax. The for loop is distinguished
by setting an explicit loop variable.
8. What is an identifier?
Identifiers are northing but names given to various entities uniquely identified in a
program. The name of identifiers must differ in spelling or casing. For
example, MyProg and myProg are two different identifiers. Programming languages,
such as C# and Visual Basic, strictly restrict the programmers from using any
keyword as identifiers. Programmers cannot develop a class whose name is public,
because, public is a keyword used to specify the accessibility of data in programs.
The switch statement is a selection control statement that is used to handle multiple
choices and transfer control to the case statements within its body. The following
code snippet shows an example of the use of theswitch statement in C#:
switch(choice)
{
66
case 1:
[Link]("First");
break;
case 2:
[Link]("Second");
break;
default:
[Link]("Wrong choice");
break;
}
In switch statements, the break statement is used at the end of a case statement.
The break statement is mandatory in C# and it avoids the fall through of
one case statement to another.
Keywords are those words that are reserved to be used for a specific task. These
words cannot be used as identifiers. You cannot use a keyword to define the name of
a variable or method. Keywords are used in programs to use the features of object-
oriented programming.
For example, the abstract keyword is used to implement abstraction and the inherits
keyword is used to implement inheritance by deriving subclasses in C# and Visual
Basic, respectively.
11. Briefly explain the characteristics of value-type variables that are supported
in the C# programming language.
The variables that are based on value types directly contain values. The
characteristics of value-type variables that are supported in C# programming
language are as follows:
67
The syntax of using the while loop in C# is:
while(condition) //condition
{
//statements
}
You can find an example of using the while loop in C#:
int i = 0;
while(i < 5)
{
[Link]("{0} ", i);
i++;
}
Value type - Refers that you do not need to provide any keyword with a
parameter.
Reference type - Refers that you need to mention the ref keyword with a
parameter.
Output type - Refers that you need to mention the out keyword with a
parameter.
Optional parameter - Refers to the new parameter introduced in C# 4.0. It
allows you to neglect the parameters that have some predefined default values.
The example of optional parameter is as follows:
public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */
Sum(10, 20); //10 + 20 + 0 + 0
Sum(10, 20, 30); //10 + 20 + 30 + 0
Sum(10, 20, 30, 40); //10 + 20 + 30 + 40
Named parameter - Refers to the new parameter introduced in C# 4.0. Now
you can provide arguments by name rather than position. The example of the
named parameter is as follows:
public void CreateAccount(string name, string address = "unknown", int age
= 0);
CreateAccount("Sara", age: 30);
CreateAccount(address: "India", name: "Sara");
68
14. Briefly explain the characteristics of reference-type variables that are
supported in the C# programming language.
The variables that are based on reference types store references to the actual data. The
keywords that are used to declare reference types are:
1. Class - Refers to the primary building block for the programs, which is used
to encapsulate variables and methods into a single unit.
2. Interface - Contains only the signatures of methods, properties, events, or
indexers.
3. Delegate - Refers to a reference type that is used to encapsulate a named or
anonymous method.
Boolean Literals - Refers to the True and False literals that map to the true and
false state, respectively.
Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal
(base 16), or octal (base 8).
Floating-Point Literals - Refers to an integer literal followed by an optional
decimal point By default, a floating-point literal is of type Double.
String Literals - Refers to a sequence of zero or more Unicode characters
beginning and ending with an ASCII double-quote character.
Character Literals - Represents a single Unicode character of the Char type.
Date Literals - Represents time expressed as a value of the Date type.
Nothing - Refers to a literal that does not have a type and is convertible to all
types in the type system.
Boolean literals - Refers to the True and False literals that map to the true and
false states, respectively.
Integer literals - Refers to literals that are used to write values of types int,
uint, long, and ulong.
Real literals - Refers to literals that are used to write values of types float,
double, and decimal.
Character literals - Represents a single character that usually consists of a
character in quotes, such as 'a'.
String literals - Refers to string literals, which can be of two types in C#:
A regular string literal consists of zero or more characters enclosed in
double quotes, such as "hello".
A verbatim string literal consists of the @ character followed by a
double-quote character, such as @"hello".
69
The Null literal - Represents the null-type.
The sub-procedure is a block of multiple visual basic statements within Sub and End
Sub statements. It is used to perform certain tasks, such as changing properties of
objects, receiving or processing data, and displaying an output. You can define a sub-
procedure anywhere in a program, such as in modules, structures, and classes.
We can also provide arguments in a sub-procedure; however, it does not return a new
value.
The function is also a set of statements within the Function and End Function
statements. It is similar to sub-procedure and performs the same task. The main
difference between a function and a sub-procedure is that sub-procedures do not
return a value while functions do.
int a = 29;
a--;
a -= ++a;
[Link]("The value of a is: {0}", a);
When a value type is converted to an object type, the process is known as boxing;
whereas, when an object type is converted to a value type, the process is known as
unboxing.
Boxing and unboxing enable value types to be treated as objects. Boxing a value type
packages it inside an instance of the Object reference type. This allows the value type
to be stored on the garbage collected heap. Unboxing extracts the value type from the
object. In this example, the integer variable i is boxed and assigned to object obj.
Example:
int i = 123;
object obj = i; /* Thi line boxes i. */
/* The object obj can then be unboxed and assigned to integer variable i: */
i = (int)obj; // unboxing
70
19. Give the syntax of using the for loop in C# code?
In the preceding syntax, initializer is the initial value of the variable, condition is the
expression that is checked before the execution of the for loop, and loop expression
either increments or decrements the loop counter.
The example of using the for loop in C# is shown in the following code snippet:
for(int i = 0; i < 5; i++)
[Link]("Hello");
In the preceding code snippet, the word Hello will be displayed for five times in the
output window.
Windows Controls - .NET Interview Questions and Answers
The Button control has the AutoSize property, which can be set to true or false. If we
set the value of theAutoSize property to true, then the button control automatically
alters its size according to the content displayed on it.
The Button class contains the Image property, which is used to set an image on
the Button control. We can also set the alignment of the image by using
the ImageAlign property of the Button class.
3. Which method is used to generate the click event of the Control class for
the Button control in C#?
The PerformClick() method of the Button class is used to generate the Click event of
[Link] class.
4. A Windows Form will not show the Minimize, Maximize, and Close buttons, if
the ControlBox property of the form is set to False. (True/False)
True.
71
Docking refers to attaching a control to either an edge (top, right, bottom, or left) or
the client area of the parent control. On the other hand, anchoring is a process in
which you need to specify the distance that each edge of your control maintains from
the edges of the parent control.
6. How can you display a default value in the text box of an input box?
You can display a default value in the text box of an input box by using
the DefaultResponse argument of theInputBox() function.
To pick a color from the color dialog box, you need to create an instance of
the ColorDialog box and invoke to the ShowDialog() method. The code to display the
color dialog box and set the BackColor property of the Label control similar to the
color selected in the color dialog box control is:
8. How can you get or set the time between Timer ticks?
There is an Interval property, which is responsible to get and set the time in
milliseconds.
The RichTextBox control contains the Lines array property, which displays one item
of an array in a separate line. Each line entry has a Length property, which can be
used to accurately position the cursor at a character, as shown in the following code
snippet:
72
[Link](offset + Column, 0);
}
11. Where does an ImageList control appear when you add it at the design time?
To avoid dropping of a Combobox, you need to override the WndProc() method and
ignore WM_LBUTTONDOWNand WM_LBUTTONDBLCLK events.
13. What is the function of the CheckState property of the CheckBox control?
If the ThreeState property is set to false, the CheckState property value can only be
set [Link] in code and not by user interaction.
Checked - The CheckBox displays a check mark. The control appears sunken.
Unchecked - The CheckBox is empty. The control appears raised.
Indeterminate - The CheckBox displays a check mark and is shaded.
To select an item from the ListView control, you can use the following code snippet:
The TextBox control is an input control, which allows a user to enter text to an
application at runtime. By default, it allows only single line text; however, you can
73
change its property to accept the multiline text as well as scroll bar also.
The RichTextBox control is similar to the TextBox control with the difference that it
allows the user to format its text also. You can format the text in various ways, such
as bold, italic, and underlined as well as change its color and font. You can save
your RichTextBox value to a RTF (Rich Text Format) file and load value of RTF
file to the RichTextBox control.
16. Describe the ToolTip control. How can you associate it with other controls?
The ToolTip control generates a small pop-up window with explanatory text for an
element It is displayed when the user pauses the mouse for a certain period over an
element/control. Tool tips provide a quick help to user to understand about that
element. To associate a tool tip with other control, you need to implement
theSetToolTip() method.
The DialogResult property retrieves or sets a value that is returned to the parent form
when the button is clicked.
The TrackBar control, also known as the slider control, works as a navigator to
display a large amount of information or for visual adjustment of numeric setting.
There are two parts in a TrackBar control - thumb (also known as slider) and tick
marks. The thumb part acts as a slider. You can adjust the thumb part using the Value
property. The tick marks are visual indicators that are spaced at regular intervals.
An MDI form closely resembles a standard form with one major difference-the client
area of an MDI form acts as a container for other forms. It means that an MDI form,
also known as an MDI parent form, can display MDI child forms inside it.
21. Which method provides the functionality to display a dialog box at runtime?
The ShowDialog() method is used to display the dialog box at run time.
The PerformStep() method increases the value of Progress bar according to the
amount set by the Stepproperty.
74
23. Write a method to get only the name of a file from the complete path string
in C#.
Use a FileInfo class and instantiate its object with the full path as the constructor
argument and then simply call the [Link] file and you will get just the name
of the file.
24. What does the OpenFile() method of the OpenFileDialog control do?
The OpenFile() method opens the file selected by the user with read-only permission.
The file is specified by the FileName property.
25. How do you retrieve the customized properties of a .NET application from
the XML .config file?
26. What is the difference between a toolstrip drop-down button and a toolstrip
split button?
The difference between a toolstrip drop-down button and a toolstrip split button is
that a toolstrip split button is a combination of two controls - a push button and a
drop-down button; whereas, a toolstrip drop-down button is a single control.
27. Which event of a TextBox control helps in restricting a text box from
accepting numeric digits in .NET 4.0?
The KeyPress event of a text box is used to restrict it from accepting numeric digits or
any other character.
28. How would you create an ellipse, which is a non- rectangular window?
Open a new Windows form, which is by default rectangular in design and then set
the TransparencyKeyproperty to the same value as BackColor, which will effectively
make the background of the form transparent. Then, set
the FormBorderStyle property to [Link], which removes the contour
and contents of the form.
29. What does the Checked property of the DateTimePicker control do?
The Checked property holds either true or false value. It holds true, when the Value
property hold a valid date-time value and is updatable; otherwise, false.
30. Name the classes used to handle standard menu in a MenuStrip control.
The two main classes used to handle standard menu in a MenuStrip control are:
75
MenuStrip - Acts as a container for the menu structure of a form.
ToolStripMenuItem - Supports the items in a menu system (including the
menus, such as File and Edit).
31. How can you attach a horizontal scroll bar with the ListBox control?
You need to set the the MultiColumn property of the ListBox control to True to attach
a horizontal scroll bar with it.
32. What is the difference between the Add() and Insert() methods of
a ListBox control?
The Add() method simply adds an item into the list box; whereas, the Insert() method
inserts an item at the specified index.
33. Consider a situation where you have added panels in a StatusBar control;
however, they are not displayed at run time. What could be the reason for this?
To display panels in the StatusBar control, the ShowPanels property needs to be set
to true.
34. What is the function of the SizeMode property of the PictureBox control?
35. How can you prevent users of an application from editing the text in
the ComboBox controls in .NET 4.0?
The ComboBox class contains the DropDownStyle property, which is used to define
the display style of the items in the ComboBox control. The DropDownStyle property
accepts a value from the ComboBoxStyleenumeration, which contains three members
to define the styles for the items: Simple, DropDownList, andDropDown.
The DropDownList value of the ComboBoxStyle enumeration is selected to set
a ComboBox control as non-editable by users, as shown in the following code
snippets:
76
Code for VB:
[Link] = [Link]
[Link] = [Link];
36. Which class manages the event and layout of all ToolStrip elements?
The ToolStripItem class manages the event and layout of all elements that
the ToolStrip control contains.
The PictureBox control offers the BorderStyle property, which can be set to define
the style of its border. This property can accept any of the three values
from Fixed3D, FixedSingle, or None. These properties can be easily set through code
or through the Properties window of the Visual Studio IDE.
Each type has a ToString() method that can used to format date, currencies, and
numbers. You can also use the [Link]() method to format these things as well.
To format dates, use the ToString() member of the DateTime type.
39. What is the use of the Panel control? Does it display at runtime?
Panels acts as a container to group other controls. It is an important control, when you
want to show/hide a group of controls and relocate a number of controls
simultaneously.
Yes, you can add an image on the RadioButton control by setting the Image property.
42. Name the methods, available in .NET 4.0, that are used to add and delete
items from a ListBox control?
77
The following methods can be used to add and delete items from a ListBox control.
The [Link]() [Link]() methods are used to add items; whereas,
the [Link](), [Link](), [Link]() methods are used to delete
items from a ListBox control.
A Button control is an important Windows control, which provides the most common
way of creating and handling an event in the code with the help of its Click event.
44. How can you unselect the selected items in a ListView control
programmatically in .NET 4.0?
The syntax to unselect the selected items in the ListView control is shown in the
following code snippets:
[Link]()
[Link]();
45. How can you get the text of the RichTextBox control, including all rich text
format strings in .NET 4.0?
The Rtf property of the RichTextBox control is used to set or get texts, including the
RTF format code.
46. What is the use of a Timer control? Can a Timer control pause?
48. Can you write a class without specifying a namespace? Which namespace
does it belong to by default?
Yes, we can write a dass without specifying namespace and that class belongs to a
global namespace that has no name.
78
49. What are the three states set in the CheckState property of CheckBox?
Checked
Unchecked
Indeterminate
50. How can you display an icon at runtime on the StatusStrip control?
The following code snippet shows the code to display an icon at runtime on
the StatusStrip control:
[Link] = [Link]("D:\\Indiabix\\Images\\[Link]");
51. Can you add more than one item simultaneously in the ListBox control?
Yes, You can add more than one item simultaneously in the ListBox control by using
the AddRange() method.
53. What are the values that can be assigned to the DialogResult property of
a Button control?
Abort-Returns Abort
Cancel-Returns Cancel
Ignore-Returns Ignore
No-Returns No
None-Nothing is returned from the dialog box
OK-Returns OK
Retry-Returns Retry
Yes-Returns Yes
User-defined controls are particularly useful in situations where you need to enhance
the functionality of an existing control.
79
Yes, it is possible to enter more than one line in a TextBox control. To do this, you
need to set the Multilineproperty of the TextBox control to True. You can set this
property at design time as well as runtime. The syntax to set this property at runtime
is as follows:
[Link] = true;
56. How can you enable a text box to change its characters format, so that users
can enter password?
You can set the PasswordChar property of the TextBox class to True to enable it to
accept passwords. The code to change the PasswordChar property of
the TextBox class is given as follows:
[Link] = '*';
57. What does the TickFrequency property of the TrackBar control do?
The TickFrequency property gets or sets a value that specifies the distance between
ticks. By default, the distance between ticks is 1.
58. Is it possible to associate a control with more than one ContextMenu control?
No, we cannot associate a control with more than one ContextMenu control.
59. What is the difference between the Panel and GroupBox control?
The Panel and GroupBox controls both can be used as a container for other controls,
such as radio buttons and check box. The main differences between a Panel and
a GroupBox control are as follows:
61. What is the difference between a ListBox control and a ComboBox control?
With a ListBox control, the user can only make a selection from a list of items;
whereas, with a ComboBoxcontrol, the user can make a selection from the list of
items as well as can add custom entry and select the same.
80
The MinDate and MaxDate properties allow users to get and set the minimum and
maximum allowable date.
The Control class or [Link] class is the parent class for all
Window controls.
64. What is the MaskedTextBox control? What does the Mask property do?
65. How can you adjust the height of a combo box drop-down list?
You can control the height of a combo box drop-down list by setting
the MaxDropDownItems property of the combo box.
The MaxDropDownItems property sets the maximum number of entries that will be
displayed by the drop-down list.
66. How can you enforce a text box to display characters in uppercase?
The TextBox class contains the CharacterCasing property, which is used to specify
the case of the content for a text box. This property accepts a value from
the CharacterCasing enumeration of .NET Framework. The members specified in
the CharacterCasing enumeration are Lower, Upper, and Normal. You can select
any one of these enumerations as a value for the CharacterCasing property of a
specified text box, as shown in the following code snippet:
[Link] = [Link];
68. How can you check/uncheck all items in the CheckedListBox control in .NET
4.0?
To check all items in .NET, you can use the following code snippet:
Dim i as Integer
81
For i = 0 To [Link] - 1
[Link](i, True)
Next
69. How can we disable the context menu for a TextBox control?
The TextBox class contains the ContextMenuStrip property. When we set this
property to a dummy instance of the ContextMenu class, the TextBox control is
unable to provide any context menu on the right-click of the mouse.
70. How can you move and resize a control on a Windows form?
You can make use of the SetBounds() method to move as well as resize the control on
a Windows form.
The DropDownStyle property changes the style of the ComboBox control. It consists
of Simple, DropDown, andDropDownList as its values. When you select Simple,
the list of items are displayed as a ListBox control. When you select DropDown, the
list is displayed in a drop down style. When you select DropDownList, the list
displayed in a drop down style and you cannot edit its text.
72. What is the difference between pixels, points, and em's when fonts are
displayed?
A pixel is the lowest-resolution dot that the computer monitor supports. Its size
depends on user's settings and the size of the monitor. A point is always 1/72 of an
inch. An em is the number of pixels it takes to display the letter M.
82