Execute scalar is a Single value single column.
Execute Reader is a Read only forward only.
Execute Reader is a Read only forward only.
Execute Non Query is used for Insert, Update, and Delete Statements.
With examples………
Run time Master page generate?
Hi, it is possible to change
Theme and Masterpage dynamically.
But they have to be done on
Page_Preinit Event like this
page.masterpagefile
="~/SecondMaster.master"
page.Theme =
"SecondDefaultTheme"
What is
Virtual Method in .Net?
By declaring base class function as virtual, we allow the function to be overridden in any of derived class.
Example of Virtual Method in .Net:
Class parent
{
virtual void hello()
{ Console.WriteLine(“Hello from Parent”); }
}
Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }
}
static void main()
{
parent objParent = new child();
objParent.hello();
}
//Output
Hello from Child.
By declaring base class function as virtual, we allow the function to be overridden in any of derived class.
Example of Virtual Method in .Net:
Class parent
{
virtual void hello()
{ Console.WriteLine(“Hello from Parent”); }
}
Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }
}
static void main()
{
parent objParent = new child();
objParent.hello();
}
//Output
Hello from Child.
What is polymorphism?
It is the important concept of OOP,
from the greek concept 'poly' means many
'morphism' means form ,from this
the definition is "the ability to
take more than one form"
EXAMPLE:
method overloading (static
polymorphism...early binding)
method overriding (dynamic
polymorphism...late binding)
Abstract class?
Virtual functions?
Diff b/w View and
Control states?
Entity framework?
LINQ queries?
How to get
largest number from comma separated string using function, using Asp.Net?
How to get
Uppercase Letter in Comma separated array?
What is
MVC, and how to implement Action Result in MVC?
All SQL
joins?
Hypertext,
Hyperlink?
Diff b/w
Datatable and DataReader?
Diff b/w
Div & Span?
How to get
2nd largest record from table field (Query)?
Passing
through reference and passing through object?
Enum: Enums store
special values. They make programs simpler. If you place constants directly
where used, your C# program becomes complex. It becomes hard to change. Enums
instead keep these magic constants in a distinct type. They improve code
clarity. http://www.dotnetperls.com/enum
What is the difference between
shadowing and overriding
|
Shadowing - Protecting against a subsequent base class
modification that introduces a member you have already defined in your derived
class
Overriding - Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence
Overriding - Achieving polymorphism by defining a different implementation of a procedure or property with the same calling sequence
What is Polymorphism in OOPS?
·
Polymorphism is one of the primary
characteristics (concept) of object-oriented programming
·
Poly means many and morph means form.
Thus, polymorphism refers to being able to use many forms of a type without
regard to the details
·
Polymorphism is the characteristic of
being able to assign a different meaning specifically, to allow an entity such
as a variable, a function, or an object to have more than one form
·
Polymorphism is the ability to
process objects differently depending on their data types
·
Polymorphism is the ability to
redefine methods for derived classes.
Delegates
A delegate is a type that references a method. Once a delegate is assigned a
method, it behaves exactly like that method. The delegate method can be used
like any other method, with parameters and a return value, as in this example:
C#
public delegate int PerformCalculation(int x, int y);
Any method that matches the delegate's
signature, which consists of the return type and parameters, can be assigned to
the delegate. This makes is possible to programmatically change method calls,
and also plug new code into existing classes. As long as you know the
delegate's signature, you can assign your own delegated method.
This ability to refer to a method as a parameter makes delegates
ideal for defining callback methods. For example, a sort algorithm could be
passed a reference to the method that compares two objects. Separating the
comparison code allows the algorithm to be written in a more general way.
Delegates
Overview
Delegates
have the following properties:
·
Delegates
are similar to C++ function pointers, but are type safe.
·
Delegates
allow methods to be passed as parameters.
·
Delegates
can be used to define callback methods.
·
Delegates
can be chained together; for example, multiple methods can be called on a
single event.
·
Methods
don't need to match the delegate signature exactly. For more information, see Covariance and Contravariance
Interfaces in C#
An interface in C# is simply a template for a class. It’s part of how C# implements polymorphism.
An interface doesn’t contain any code, only definitions of methods, properties,
events and indexers. A class that implements an interface will need to define
the code used for these items. Here’s a short code snippet of an example C#
interface…
public interface IMyItem
{
int Id { get; set; }
string Description { get; set; }
string RunTest(int testNumber);
event EventHandler TestStatus;
string this[int index] { get; set;}
}
In this example, the interface
includes two properties, a method, an event and an indexer. A class that used
this interface would need to provide code for these items. While the code
doesn’t have to do anything, it does have to be implemented by the class using
the interface.
One powerful thing that you can
do with interfaces is that you can have a class that implements more than one
interface. One of my favorite usages is to not only implement a program
specific interface but to also implement a generic List or Queue.
Abstract Classes in C#
An abstract class in C# is a
class that can’t be instantiated and, like an interface, is intended to provide
a common class definition that is shared by derived classes. Like an interface,
the routines in an abstract class may be methods, properties, indexers and
events. Unlike an interface, an abstract class may contain code although it may
also have abstract methods that do not have code. Also, an abstract class may
define constructors and destructors while an interface does not as well as
internal private and protected variables.
Here’s a simple example of a C#
abstract class…
public abstract class TestItem
{
private int _testId;
public TestItem(int testIdValue)
{
_testId = testIdValue;
}
public int TestId
{
get
{
return _testId;
}
set
{
_testId = value;
}
}
public abstract string Description { get; set; }
public abstract void RunTest(int i);
public abstract string this[int index] { get; set; }
}
Write a C program to swap two variables without using a temporary variable.
This
method is also quite popular
a=a+b;
b=a-b;
a=a-b;
a=a+b;
b=a-b;
a=a-b;
What is heap and stack?
The stack is a place in the computer memory where all the variables that
are declared and initialized before runtime are stored. The heap is the section of
computer memory where all the variables created or initialized at runtime are stored.
Swapping three variable without using
temp variable
a = 2 b = 1 c = 3
a = a+b+c = 6
b = a -b-c = 2
c = a -b- c = 1
a = a-b-c = 3
After swapping
a = 3 ; b = 2 ; c = 1
a = 2 b = 1 c = 3
a = a+b+c = 6
b = a -b-c = 2
c = a -b- c = 1
a = a-b-c = 3
After swapping
a = 3 ; b = 2 ; c = 1
What is the difference between UserControl, WebControl?
UserControl:
A custom control, ending in .ascx, that is composed of other web controls. Its
almost like a small version of an aspx webpage. It consists of a UI (the ascx)
and codebehind. Cannot be reused in other projects by referencing a DLL.
WebControl:
A control hosted on a webpage or in a UserControl. It consists of one or more
classes, working in tandem, and is hosted on an aspx page or in a UserControl.
WebControls don't have a UI "page" and must render their content
directly. They can be reused in other applications by referencing their DLLs.
base keyword
The base keyword is used to access members of the base class from within a
derived class:
- Call a method on the base class that has been overridden by another method.
- Specify which base-class constructor should be called when creating instances of the derived class.
Authentication types in web.config?
ASP.NET implements additional authentication schemes using
authentication providers, which are separate from and apply only after the IIS
authentication schemes. ASP.NET supports the following authentication providers:- Windows (default)
- Forms
- Passport
- None
IsPOSTback function in Asp.Net?
URL: Is Postback is normally used on page _load event to detect if
the page is getting generated due to postback requested by a control on the
page or if the page is getting loaded for the first time. IsPostBack is a
Boolean property of a page when is set (=true) when a page is first loaded.
Thus, the first time that the page loads the IsPostBack flag is false and for
subsequent PostBacks, it is true. Each time a PostBack occurs, the entire page
including the Page_Load is ‘posted back‘and executed.
ASP.NET: Difference between Server.Transfer and response.Redirect?
In response.redirect the browser url changes to targeted page
as well as in server.transfer the url remains same!
Response.Redirect should be
used when:
·
we want to redirect the request
to some plain HTML pages on our server or to some other web server
·
we don't care about causing
additional roundtrips to the server on each request
·
we do not need to preserve
Query String and Form Variables from the original request
·
we want our users to be able to
see the new redirected URL where he is redirected in his browser (and be able
to bookmark it if its necessary)
Server.Transfer should be used
when:
·
we want to transfer current
page request to another .aspx page on the same server
·
we want to preserve server
resources and avoid the unnecessary roundtrips to the server
·
we want to preserve Query
String and Form Variables (optionally)
·
we don't need to show the real
URL where we redirected the request in the users Web Browser
Round-trip –
Response.Redirect() first sends request for new page to the browser, then
browser sends that request to the web-server, and after that your page changes.
But Server.Transfer() directly communicate with the server to change the page
hence it saves an extra round-trip (to the browser) in the whole process.
Difference Between Web.Config file and Global.asax ?
Web.Config file is used.... 1. To specify the application settings 2. To specify the session mechanism available to use for that application. 3. To Specify the Connection strings. 4. To Specify the authentication and authorization. 5. To Specify the http handlers. 6. To Specify different providers. Global.asax file is used to specify the session and application event handlers. which is handling application level events and session level events..
Advantages and
Disadvantages of Session
Advantages:
* It helps to maintain user states and data to all over the application.
* It can easily be implemented and we can store any kind of object.
* Stores every client data separately.
* Session is secure and transparent from user.
Disadvantages:
* Performance overhead in case of large volume of user, because of session data stored in server memory.
* Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer and SQLServer session mode we need to serialize the object before store.
* It helps to maintain user states and data to all over the application.
* It can easily be implemented and we can store any kind of object.
* Stores every client data separately.
* Session is secure and transparent from user.
Disadvantages:
* Performance overhead in case of large volume of user, because of session data stored in server memory.
* Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer and SQLServer session mode we need to serialize the object before store.
ADO.Net encapsulates our
queries and commands to provide a uniform access to various database management
systems. ADO.Net is a successor of ADO (ActiveX Data Object). The prime
features of ADO.Net are its disconnected data access architecture and XML
integration.
Access Data Object simply stood for
"ADO". EXTENSION OF ADO.NET is Activex Data Object . main use of
capturing datasource for bridge between the application layer to the database
layer. in other words interaction between application to database with proper
connection string under configurations
What is indexing?
Indexing
is a way of sorting a number of records on multiple fields. Creating an index
on a field in a table creates another data structure which holds the field
value, and pointer to the record it relates to. This index structure is then
sorted, allowing Binary Searches to be performed on it.
TRIGGERS
A Trigger is a named database object which defines some
action that the database should take when some databases related event occurs.
Triggers are executed when you issues a data manipulation command like INSERT,
DELETE, UPDATE on a table for which the trigger has been created. They are
automatically executed and also transparent to the user. But for creating the
trigger the user must have the CREATE TRIGGER privilege. In this section we
will describe you about the syntax to create and drop the triggers and describe
you some examples of how to use them.
CREATE TRIGGER
The general syntax of CREATE TRIGGER is :
CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_statement
CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_statement
What are
the differences between final, finally, finalize Methods?
final is a keyword. It’s constant. It can’t be changed from its initiated value.
finally() method used exception handling concept.finally() block will execute whether or not try block can be execute. It’s used to close a file.
finalize is used when an object is just before deleted, it can be used in garbage collection.
Accessing Arrays
We can access an array item by passing the item index in the
array. The following code snippet creates an array of three items and displays
those items on the console.
// Initialize a fixed array one item
at a time
int[]
staticIntArray = new int[3];
staticIntArray[0] = 1;
staticIntArray[1] = 3;
staticIntArray[2] = 5;
// Read array items one by one
Console.WriteLine(staticIntArray[0]);
Console.WriteLine(staticIntArray[1]);
Console.WriteLine(staticIntArray[2]);
http://www.c-sharpcorner.com/uploadfile/mahesh/workingwitharrays11232005064036am/workingwitharrays.aspx
This comment has been removed by a blog administrator.
ReplyDelete