JEYAGANESH

JEYAGANESH
Software Developer

Sunday, 18 December 2011

Wcf Concepts












Wcf Architecture
---------------------------------------------------------------------------------------------------------
Sample Image - maximum width is 600 pixels


For Details contact:   http://www.codeproject.com/KB/WCF/WCF_Basics.aspx

Friday, 16 December 2011

C# Questions And Answers

C# Questions And Answers
--------------------------------------

What’s the difference between private and shared assembly? 
Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.
 

What’s a strong name? 
A strong name includes the name of the assembly, version number, culture identity, and a public key token.

Where are shared assemblies stored? 
Global assembly cache.

What is a satellite assembly? 
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

What namespaces are necessary to create a localized application? 
System.Globalization, System.Resources.

Which one is trusted and which one is untrusted? 
Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction

Difference between value and reference type. what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
 

What are the two kinds of properties. 
Two types of properties in .Net: Get and Set

Which controls do not have events? 
Timer control.

What is the maximum size of the textbox? 
65536.

Which property of the textbox cannot be changed at runtime? 
Locked Property.

Does C# support multiple-inheritance? 
No.uses Interface

What’s the top .NET class that everything is derived from? 
System.Object.

What is the .NET datatype that allows the retrieval of data by a unique key? 
HashTable.

What is a delegate?
delegate is a type safe function pointer. Using delegates you can pass methods as parameters. To pass a method as a parameter, to a delegate, the signature of the method must match the signature of the delegate. This is why, delegates are called type safe function pointers.
What is the main use of delegates in C#?
Delegates are mainly used to define call back methods.

What do you mean by chaining delegates?
Or
What is a multicast delegate?

The capability of calling multiple methods on a single event is called as chaining delegates. Let me give you an example to understand this further.
1. Create a new asp.net web application
2. Drag and drop a button control and leave the ID as Button1. 
3. On the code behind file, add the code shown below.


When you click the Button now, both Method1 and Method2 will be executed. So, this capability of calling multiple methods on a single event is called as chaining delegates. In the example, we are using EventHandler delegate, to hook up Method1 and Method2 to the click event of the button control. Since, the EventHandler delegate is now pointing to multiple methods, it is also called as multicast delegate.

Will the following code compile?

No, the code does not compile. For the code to compile, the signature of Method1 should match the signature of SampleDelegate.
---------------------------------------------------------------------------------------
It is very important to keep the following points in mind when creating partial classes.
1. All the parts must use the partial keyword.
2. All the parts must be available at compile time to form the final class.
3. All the parts must have the same access modifiers - public, private, protected etc.
4. Any class members declared in a partial definition are available to all the other parts. 
5. The final class is the combination of all the parts at compile time.

What are the advantages of using partial classes?
1. When working on large projects, spreading a class over separate files enables multiple programmers to work on it at the same time.

2. When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when it creates Windows Forms, Web service wrapper code, and so on. You can create code that uses these classes without having to modify the file created by Visual Studio.

Is it possible to create partial structs, interfaces and methods?
Yes, it is possible to create partial structs, interfaces and methods. We can create partial structs, interfaces and methods the same way as we create partial classes.

Diff between System.Array.CopyTo() and System.Array.Clone()

Diff between System.Array.CopyTo() and System.Array.Clone()
------------------------------------------------------------------

System.Array.CopyTo()-Copy the structure and value of the array

System.Array.Clone()-Only Copy the structure of the array

Wednesday, 23 November 2011

Stored Procedures

Stored procedures are a powerful part of SQL Server. They can assist programmers and administrators greatly in working with the database configuration and its data.
A stored procedure is a precompiled group of Transact-SQL statements, and is saved to the database (under the "Stored Procedures" node). Programmers and administrators can execute stored procedures either from the SQL Server Management Studio or from within an application as required.
Transact-SQL, which is based on SQL (Structured Query Language), is the programming language used to interface between applications and their databases. Transact-SQL is a relatively easy language to learn and I highly recommend becoming familiar with it.

Benefits of Stored Procedures

Here are some key benefits in using stored procedures:
BenefitExplanation of benefit
Modular programmingYou can write a stored procedure once, then call it from multiple places in your application.
PerformanceStored procedures provide faster code execution and reduce network traffic.
  • Faster execution: Stored procedures are parsed and optimized as soon as they are created and the stored procedure is stored in memory. This means that it will execute a lot faster than sending many lines of SQL code from your application to the SQL Server. Doing that requires SQL Server to compile and optimze your SQL code every time it runs.
  • Reduced network traffic: If you send many lines of SQL code over the network to your SQL Server, this will impact on network performance. This is especially true if you have hundreds of lines of SQL code and/or you have lots of activity on your application. Running the code on the SQL Server (as a stored procedure) eliminates the need to send this code over the network. The only network traffic will be the parameters supplied and the results of any query.
SecurityUsers can execute a stored procedure without needing to execute any of the statements directly. Therefore, a stored procedure can provide advanced database functionality for users who wouldn't normally have access to these tasks, but this functionality is made available in a tightly controlled way.

Creating a Stored Procedure

You create stored procedures in the SQL Server Management Studio using the CREATE PROCEDURE statement, followed by the code that makes up the stored procedure.

CREATE PROCEDURE StoredProcedureName AS
...
The following code creates a stored procedure called "MyStoredProcedure":

CREATE PROCEDURE MyStoredProcedure AS
SET ROWCOUNT 10
SELECT Products.ProductName AS TenMostExpensiveProducts, Products.UnitPrice
FROM Products
ORDER BY Products.UnitPrice DESC 
 
Please refer:http://www.quackit.com/sql_server/sql_server_2008/tutorial/sql_server_stored_procedures.cfm 

ASP.NET MVC

Introduction

Well, this is my eleventh article. This time, I have tried a new idea about the HTML 5 controls for ASP.NET MVC.

What is ASP.NET MVC?

ASP.NET MVC is a part of the ASP.NET Web application framework. It is one of the two different programming models you can use to create ASP.NET Web applications, the other being ASP.NET Web Forms.
An MVC Application is designed and implemented using the following three attributes:
What-Is-MVC.png
  • Model: The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic.
  • View: The view encapsulates the presentation of the application, and in ASP.NET this is typically the HTML markup.
  • Controller: The controller contains the control-flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.
This separation of entity allows you to have nimbleness and flexibility in building and maintaining your application. For example, by separating the views, you can iterate on the appearance of your application without touching on any of the core business logic. You can also separate work by role, so that, for example designers can work on the views, while developers work on the model.
ASP.NET MVC brings the power of this development paradigm to ASP.NET development, allowing you to use your .NET development skills to build MVC applications.
It:
  • gives you complete control over your HTML Markup
  • enables rich AJAX and jQuery integration
  • allows you to create SEO-friendly URLs for your site
  • makes Test Driven Development (TDD) easy

Friday, 12 August 2011

Sample Code For Asp.net

===== Inline code =====
<source lang="csharp">
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "---//W3C//DTD XHTML 1.0 //EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
// Assign the datetime to label control
lbl1.Text = DateTime.Now.ToLongTimeString();

}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Sample page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
The current time is: <asp:Label runat="server" id="lbl1" />
</div>
</form>
</body>
</html>
</source>
The above page renders with the Text "The current time is: " and the <asp:Label> Text is set with the current time, upon render.