Introduced with C#4.0 as a new
features?
Covariance and Contravariance are
introduced as a new features with C#4.0 Covariance and contravariance enable
implicit reference conversion for array types, delegate types, and generic type
arguments. Covariance preserves assignment compatibility and contravariance
reverses it.
What are namespaces, and how they are used?
Namespaces are used to organize classes within the
.NET Framework. They dictate the logical structure of the code. They are
analogous to Java packages, with the key difference being Java packages define
the physical layout of source files (directory structure) while .NET namespaces
do not. However, many developers follow this approach and organize their C#
source files in directories that correlate with namespaces. The .NET Framework
has namespaces defined for its many classes, such as System.Xml--these are
utilized via the using statement. Namespaces are assigned to classes via the
namespace keyword.
What is a constructor?
A constructor is a class member executed when an
instance of the class is created. The constructor has the same name as the
class, and it can be overloaded via different signatures. Constructors are used
for initialization chores.
What is the GAC, and where is it located?
The GAC is the Global Assembly Cache. Shared
assemblies reside in the GAC; this allows applications to share assemblies
instead of having the assembly distributed with each application. Versioning
allows multiple assembly versions to exist in the GAC--applications can specify
version numbers in the config file. The gacutil command line tool is used to manage
the GAC.
Why are strings in C# immutable?
Immutable means string values cannot be changed
once they have been created. Any modification to a string value results in a
completely new string instance, thus an inefficient use of memory and
extraneous garbage collection. The mutable System.Text.StringBuilder class
should be used when string values will change.
What is DLL Hell, and how does .NET solve it?
DLL Hell describes the difficulty in managing DLLs
on a system; this includes multiple copies of a DLL, different versions, and so
forth. When a DLL (or assembly) is loaded in .NET, it is loaded by name,
version, and certificate. The assembly contains all of this information via its
metadata. The GAC provides the solution, as you can have multiple versions of a
DLL side-by-side.
How are methods overloaded?
Methods are overloaded via different signatures
(number of parameters and types). Thus, you can overload a method by having
different data types, different number of parameters, or a different order of
parameters.
How do you prevent a class from being inherited?
The sealed keyword prohibits a class from being
inherited.
What is the execution entry point for a C# console application?
The Main method.
How do you initiate a string without escaping each backslash?
You put an @ sign in front of the double-quoted
string.
String ex
= @"This has a carriage return\r\n"What is the difference between a struct and a class?
Structs cannot be inherited. Structs are passed by
value and not by reference. Structs are stored on the stack not the heap. The
result is better performance with Structs.
What is a singleton?
A singleton is a design pattern used when only one
instance of an object is created and shared; that is, it only allows one
instance of itself to be created. Any attempt to create another instance simply
returns a reference to the first one. Singleton classes are created by defining
all class constructors as private. In addition, a private static member is
created as the same type of the class, along with a public static member that
returns an instance of the class. Here is a basic example:
public
class SingletonExample {private static SingletonExample _Instance;
private SingletonExample () { }
public static SingletonExample GetInstance() {
if (_Instance == null) {
_Instance = new SingletonExample ();
}
return _Instance;
}
}
What is boxing?
Boxing
is the process of explicitly converting a value type into a corresponding
reference type. Basically, this involves creating a new object on the heap and
placing the value there. Reversing the process is just as easy with unboxing,
which converts the value in an object reference on the heap into a
corresponding value type on the stack. The unboxing process begins by verifying
that the recipient value type is equivalent to the boxed type. If the operation
is permitted, the value is copied to the stack.
Difference Between Tostring() & convert.tostring()
Just to give an understanding of what the above
question means see the below code.
int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));
We can convert the integer “i” using “i.ToString()”
or “Convert.ToString” so
what’s the difference.
The basic difference between them is “Convert”
function handles NULLS while “i.ToString()”
does not handle nulls it will throw a NULL
reference exception error.
So as good coding practice using “convert” is
always safe.
Disable Cut, Copy & Paste in a Text
Box Without using java Script IN C#
Disable Copy and Paste in an ASP.NET Webpage TextBox without
JavaScript; we need to set the following properties of the TextBox:
- oncut="return false"
- oncopy="return false"
- onpaste="return false"
Now the source code of the Default.aspx should
look as in the following:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<%--added
by vithal wadje--%>
<div>
<asp:TextBox ID="TextBox1" runat="server" oncopy="return false" onpaste="return false"
oncut="return false" TextMode="MultiLine">
</asp:TextBox>
</div>
</form>
</body>
</html>
What is Satelite Assembly?
A satellite assembly is a .NET Framework assembly containing resources specific to a given language.
Using satellite assemblies, you can place resources
for different languages in different assemblies, and the correct assembly is
loaded into memory only if the user selects to view the application in that
language.
.Net Threading
Thread in computer science means a
sequence of execution instructions that can run independently , that is a
single flow of execution in a process. Thread is like a process, at least one
thread exists within each process. Single Thread (normal programs) in computer
science means that only one task can execute and at the same time the other
tasks have to wait for the completion of the current task like in a queue.
Single thread resulted in systems idle time and application performance.
Multithreading allows multiple process to execute
concurrently within a single program .That is more than one task in a program
can execute at the same time and each thread run independently of its own. If
multiple threads can exist within a process, typically share the state
information of a process, and share memory and other resources directly. Each
thread maintains exception handlers, a scheduling priority, and a set of
structures the system uses to save the thread context until it is scheduled.
In multiple threaded programming we can use system's idle
time, so it leads improved application performance . Also we can set priority
in each Threads . Threads with higher priority are executed in preference to
threads with lower priority. It is recommended that you use as few threads as
possible, thereby minimizing the use of Operating System resources .
.Net Code Access Security
The .NET Security Model provides code access permissions and
code identity permissions. Code Access Security is the part of the .NET
security model that determines whether or not the code is allowed to run, and
what resources it can use when it is running. Code Access Security policy uses
evidence to help grant the right permissions to the right assembly.
An administrator can configure Code Access Security policy to
restrict the resource types that code can access and the other privileged
operations it can perform. Code Access Security allows code to be trusted to
varying degrees depending on where the code originates and on other aspects of
the code's identity. Code Access Security can also help minimize the damage
that can result from security vulnerabilities in your code.
Design Pattern in Dotnet
Design Pattern in Dotnet
1. Adapter Design Pattern - C#
2. Composite Design Pattern - C#
3. Bridge Design Pattern - C#
4. Decorator Design Pattern - C#
5. Prototype Design Pattern - C#
6. Proxy Design Pattern - C#
7. Singleton Design Pattern - C#
8. Chain of Responsibility Design Pattern - C#
9. Flyweight Design Pattern - C#
10. Facade Design Pattern - C#
11. Command Design Pattern - C#
12. Builder Design Pattern - C#
13. Abstract
Factory Design Pattern - C#
14. Factory Method Design Pattern - C#
Adapter Design Pattern
- C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/Y3OI080713-Adapter-Design-Pattern---C#.html>
Adapter pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. The Adapter pattern allows a system
to use
classes of another system that is incompatible with it. It
is especially
used for toolkits and libraries. In this article, I would
like share
what is adapter pattern and how is it work?
Composite Design Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/XSN6130713-Composite-Design-Pattern---C#.html>
Composite pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. Composite Pattern is used to
arrange structured
hierarchies. In this article, I would like share what is
composite
pattern and how is it work?
Bridge Design Pattern
- C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/W387130713-Bridge-Design-Pattern---C#.html>
Bridge pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. All we know, Inheritance is a way
to specify
different implementations of an abstraction. But in this
way,
implementations are tightly bound to the abstraction and can
not be
modified independently.
Decorator Design
Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/VRQT130713-Decorator-Design-Pattern---C#.html>
Decorator pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. Decorator pattern is used to add
new
functionality to an existing object without changing its
structure.
Hence Decorator pattern provides an alternative way to inheritance
for
modifying the behavior of an object. In this article, I
would like share
what is decorator pattern and how is it work?
Prototype Design Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/R9R4060613-Prototype-Design-Pattern---C#.html>
Prototype pattern is used to create a duplicate object or
clone of the
current object to enhance performance. This pattern is used
when
creation of object is costly or complex.
Proxy Design Pattern
- C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/P40W140713-Proxy-Design-Pattern---C#.html>
Proxy pattern falls under Structural Pattern of Gang of Four
(GOF)
Design Patterns in .Net. The proxy design pattern is used to
provide a
surrogate object, which references to other object. In this
article, I
would like share what is proxy pattern and how is it work?
Singleton Design
Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/L2KL080613-Singleton-Design-Pattern---C#.html>
Singleton pattern is one of the simplest design patterns.
This pattern
ensures that a class has only one instance and provides a
global point
of access to it.
Chain of
Responsibility Design Pattern - C#
Chain of Responsibility pattern falls under Behavioural
Pattern of Gang
of Four (GOF) Design Patterns in .Net. The chain of
responsibility
pattern is used to process a list or chain of various types
of request
and each of them may be handle by a different handler. In
this article,
I would like share what is chain of responsibility pattern
and how is it
work?
Flyweight Design Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/cWHV140713-Flyweight-Design-Pattern---C#.html>
Flyweight pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. Flyweight pattern try to reuse
already existing
similar kind objects by storing them and creates new object
when no
matching object is found. In this article, I would like
share what is
flyweight pattern and how is it work?
Facade Design Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/1N4c140713-Facade-Design-Pattern---C#.html>
Facade pattern falls under Structural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. The Facade design pattern is
particularly used
when a system is very complex or difficult to understand
because system
has a large number of interdependent classes or its source
code is
unavailable. In this article, I would like share what is
facade pattern
and how is it work?
Command Design
Pattern - C#
Command pattern falls under Behavioural Pattern of Gang of
Four (GOF)
Design Patterns in .Net. The command pattern is commonly
used in the
menu systems of many applications such as Editor, IDE etc.
In this
article, I would like share what is command pattern and how
is it work?
Builder Design
Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/6aMR040613-Builder-Design-Pattern---C#.html>
Builder pattern builds a complex object by using simple
objects and a
step by step approach. Builder class builds the final object
step by
step. This builder is independent of other objects. The
builder pattern
describes a way to separate an object from its construction.
The same
construction method can create different representation of
the object.
Abstract Factory Design Pattern - C#
http://www.dotnet-tricks.com/Tutorial/designpatterns/4EJN020613-Abstract-Factory-Design-Pattern---C#.html>
Abstract Factory method pattern falls under Creational
Pattern of Gang
of Four (GOF) Design Patterns in .Net. It is used to create
a set of
related objects, or dependent objects. Internally, Abstract
Factory use
Factory design pattern for creating objects. It may also use
Builder
design pattern and prototype design pattern for creating
objects.
Factory Method Design
Pattern - C#
<http://www.dotnet-tricks.com/Tutorial/designpatterns/FUcV280513-Factory-Method-Design-Pattern---C#.html>
In Factory pattern, we create object without exposing the
creation
logic. In this pattern, an interface is used for creating an
object, but
let subclass decide which class to instantiate. The creation
of object
is done when it is required. The Factory method allows a
class later
instantiation to subclasses.
Understanding MVC,
MVP and MVVM Design Patterns
There are three most popular MV-* design patterns: MVC, MVP
and MVVM.
Follow url:- http://designpatternsindotnet.blogspot.in/
No comments:
Post a Comment