Sunday, July 31, 2011

Difference Between Structure and Class?

Difference Between Structure and Class?


Structure

Class

Structure is a Value type and stored in stack.

Class is a reference type and stored in heap.

Structures do not support inheritance.

Classes support inheritance.

By default all members of Structure are public.

In case of Class, all constants and variables are private while other members of
the Class are public by default.

Structure members can't be declared Protected.

Class members can be declared Protected.

A Structure cannot be fully empty.

A Class can be fully empty.

A Structure does not need a constructor.

A Class needs a constructor.

Finalize method is never called for Structures as they are never terminated.

Finalize method is called for Classes as they are terminated by GC (Garbage collector)
that calls the Finalize method.

Even after assigning the value nothing to a Structure variable, instance continues
to be associated with the variable and we can access its data members.

In Class, if we assign nothing to object variable we cannot access any member through
the variable until you assign another instance to it.

Boxing of a Structure object creates a copy of the object in a different type.

Boxing a Class object creates a reference (of different type) to the same object.

Structure are value type it is not possible to assign null to a Structure object.

Classes are reference type so it is possible to assign null value to Class object.

Differences between an interface and an abstract class?

Difference Between an Interface and an Abstract class?


Interface

Abstract class

An Interface is used to define methods (have no Body) but not for the implementation.

An Interface abstract class can be used to implement the Methods.

An Interface allows us to use multiple inheritance.

An Abstract Classes does not allows us to use multiple inheritance.

Interfaces are slow.

Abstract classes are fast.

When we have similar classes that will share code use an abstract class.

When we have classes that are nothing to do with one another but share some aspect
that they do not share a common ancestor then use an interface.

An Interface cannot implement methods.

An abstract class can implement methods.

An Interface can only inherit from another Interface.

An abstract class can inherit from a class and one or more interfaces

An Interface cannot contain fields.

An abstract class can contain fields.

An Interface can contain property definitions.

An abstract class can implement a property.

An Interface cannot contain constructors or destructors.

An abstract class can contain constructors or destructors.

An Interface can be inherited from by structures.

An abstract class cannot be inherited from by structures.

An Interface can support multiple inheritances.

An abstract class cannot support multiple inheritances.

Tuesday, July 26, 2011

Help File Generation for ASP.NET Website Project

Help File Generation for ASP.NET Website Project(Using Sandcastle)



It is very easy to create a help file. If you have followed the practice of putting standard XML comments into your .NET code, for code commenting, install Ghost Doc which is available at http://submain.com/download/ghostdoc/. After installation right click on the code and click on “Document This” which will automatically insert the commenting structure like:
     /// <summary>
     ///
     /// </summary>
     /// <returns></returns>
 It is very easy to generate help file based on that. Here are the steps to achieve this
1.       Install Sandcastle from here: http://sandcastle.codeplex.com/
2.       Install Sandcastle Help File Builder GUI from here: http://shfb.codeplex.com/
3.       Install HTML Help 1.x Compiler from here: http://go.microsoft.com/fwlink/?LinkId=14188
4.       Download the EWSoftware.CodeDom.dll from here: http://sandcastlestyles.codeplex.com/releases/view/22689
Add a reference to the above mentioned dll in your project.
5.       Add the following  to the <compilers> section within <system.codedom> section of the web.config:
<compiler language="c#;cs;csharp" extension=".cs"
          compilerOptions="/docpath:C:\Publish\Docs"
          type="EWSoftware.CodeDom.CSharpCodeProviderWithDocs,
              EWSoftware.CodeDom, Version=1.1.0.0, Culture=neutral,
              PublicKeyToken=d633d7d5b41cbb65">           
            <providerOption name="CompilerVersion" value="v3.5"/>
</compiler>
Publish the website. The XML Documentation files would be generated and can be found in the folder specified in /docpath.
              
6.       Start Sandcastle Help File Builder GUI. Go to Project Explorer. Click on Document Sources -> Add Document Source. Browse and add the App_Code.dll file and the .xml file from the /docpath folder to the project.
You may want to alter the following properties in the Project Properties window:-


Property Name
Description
HelpTitle
The title for the help file
OutputPath
The path where the help file will be generated
ShowMissingNamespaces
If set to true a message is added to the namespace help topics if the namespace comments are missing.
ShowMissingValues
If set to true a message is added to the help topic if the <value> tag is missing.
APIFilter
Used to include /exclude elements from the help file.
Note: If App_Code classes are not contained within a namespace; manually select them here to make them visible in Help file.

7.       Click on Documentation -> Build Project to generate the help file.
8.       After the build process is complete, click on Documentation -> View Help File -> View Help file.

Sunday, July 24, 2011

FREE ASP.NET TOOLS

FREE ASP.NET TOOLS


Here is a list of some great tools and add-in that every .NET developer must have:

  • Code Compare
    Visual Studio plug-in for code comparison. This is used to compare two files. This
    will automatically compare each contents of each file and tells you the difference
    between these files.
    http://www.devart.com/codecompare/

  • Resharper
    It is a kind of tool which makes easy the development environment of Visual Studio.
    It save lot of time and also guide you while coding it inspect your code at real-time.
    This maintains the standard of your code not.
    http://www.jetbrains.com/resharper/

  • SSMS Tools Pack
    Plug-in for SQL Server Management Studio that adds a good deal of functionality.
    It adds the intelligence and formatting of script which will save the time of the
    developer.
    http://www.ssmstoolspack.com/

  • LINQ Pad
    A fantastic learning tool for those who are just getting into LINQ or for those
    who want a code snippet IDE to execute any C# or VB expression.
    http://www.linqpad.net/

  • Design Patterns
    Design pattern are the solution of software development problem. Each time we face
    the same problem in the software to resolve this there must be some design pattern
    while developing the application
    http://www.dofactory.com/Patterns/Patterns.aspx

Friday, July 15, 2011

Reset Identity value of a column in SQL Server

Reset Identity value of a column in SQL Server


You can reset the identity of a column in SQL Server table. Identity column means
whose value increase automatically whenever you insert a record. But when you delete
all the records from the table and insert a new record then value of identity column
will be one(increment seed) more than the last value not starting from one. In this
situation we want to start value from 1 or any another number after deleting the
data. To reset the identity value use the below command

Suppose I have a table whose name is Login then to reset identity I can use this
command

DBCC CHECKIDENT ([Login], RESEED, 0)

To Check identity value use the below command

DBCC CHECKIDENT ([Login], NORESEED)

If you are using an identity column in SQL Server tables, you can set the next insert
value to whatever value you want.

To set the value of the next ID to be 100, you can use this command:

DBCC CHECKIDENT ([Login], RESEED, 99)

Note that the next value will be whatever you reseed with here we use + 1, so in
this case I set it to 99 so that the next value will be 100.

Wednesday, July 6, 2011

Select random rows with Microsoft SQL Server?

Select random rows in SQL Server

SELECT Top 10* FROM [Table Name] ORDER BY NEWID()

You can select top 10 random rows by the above query each time you can get different 10 rows. This query randomly select data each time when you execute query.




Count number of tables, stored procedure, function and views in sql database

Count number of tables, stored procedure, function and views in sql database

To count number of Tables in sql database
SELECT COUNT(*) FROM information_schema.tables WHERE Table_Type = 'Base Table'

To count number of Procedures in sql database
SELECT COUNT(*) FROM information_schema.routines WHERE Routine_Type = 'Procedure' 

To count number of Functions in sql database
SELECT COUNT(*) FROM information_schema.routines WHERE Routine_Type = 'Function' 

To count number of Views in sql database
SELECT COUNT(*) FROM information_schema.views

Tuesday, July 5, 2011

Turning On and Off Identity Column in SQL Server

Turning On and Off Identity Column in SQL Server

General Form
SET IDENTITY_INSERT table name ON
GO

--Sql Insert Statement here
SET IDENTITY_INSERT table name OFF
GO
When you transfer data from one table to another table using script
then you should first on the identity field of the table by using the below query 

SET IDENTITY_INSERT table name ON


Now you can write insert statement for inserting data into another table. After inserting the data into another table you should off the identity field of the table

SET IDENTITY_INSERT table name OFF

SEO Best Practices


SEO Best Practices


(SEO Best Practices for ASP.NET Web Applications)
  • Provide unique, accurate page Title. Do NOT use stop words like “.com”, particularly
    at the beginning of the Title text.
      Tips:
    • · Have unique title for each page.
    • · Use keywords in title.
  • Include proper Description Meta tags and use meaningful keywords.
  • Standardize the structure of page URLs. Organize pages into categories.
  • Ensure that all the links in your site follow same URL casing format.
    (For example, always use lowercase letters.)
  • Add an <h1> tag to the <body> section of the page to improve page relevancy.
    Use only one <h1> tag per page.
  • Make site navigation easier.
    • Tips:
    • · Use bread crumbs on pages
    • · Use relevant Sitemap
    • · Remove all broken links
  • Create a custom 404 page to be displayed when ‘page is not found’ error occurs.
  • Place an effective Robots.txt file on your server. It tells search engines what
    parts of your website should be indexed and what areas or pages should not be indexed.
  • If pages are still not being indexed, submit them to popular search engines like
    Google, Yahoo, etc. For example, for Google, you may submit a page to be indexed
    at google.com/addurl.

Insert Horizontal Lines in Word Documents Quickly

Insert Horizontal Lines in Word Documents Quickly

 

--- Thin line
Insert three or more times hyphen (-) and then press enter key 
Output will be as below



 
*** Broken line
Insert three or more times star (*) and then press enter key 
Output will be as below
 
 
### Thick line with two thin lines
Insert three or more times hash (#) and then press enter key 
Output will be as below
 
=== Double line
Insert three or more times equal to (=) and then press enter key 
Output will be as below
 
~~~ Wavy line
Insert three or more times tilde (~) and then press enter key
Output will be as below
 
 

Monday, July 4, 2011

How To Generate Dummy Text In Word 2007

How To Generate Dummy Text In Word 2007

General Representation of creating dummy text in word 2007

=Lorem(Number of Paragraphs, Number of Lines)

=Lorem(Number of Paragraphs)

=Lorem()

OR

=Rand(Number of Paragraphs, Number of Lines)

=Rand(Number of Paragraphs()

=Rand()

Parameters are optional. You can generate dummy text by using any of the above formula. After writing formula press enter key.

Suppose you want to generate dummy text with 3 paragraph and 3 lines (Line are the complete sentence) per paragraph.

You can use this formula =Rand(1,1) or =Lorem(1,1)

Note: Formula should be the first sentence of the line and after writing formula you must have to press enter key. In this way you can generate the dummy text in quick time.

Saturday, July 2, 2011

How to disable Text Area resizing

Error: Multiline Textbox resizable in Firefox and Chrome

<asp:TextBox ID="TextBox1" style="Resize:none;" TextMode="MultiLine" runat="server">
</asp:TextBox>

Using the above Style you can restrict Multiline Textbox from resizing.

Friday, July 1, 2011

Difference Between Asp.Net 2005 and Asp.Net 2008

Difference Between Asp.Net 2005 and Asp.Net 2008


ASP.NET 2005

ASP.NET 2008

32 bit support

64 bit support

Asp.net 2.0 includes the following as new features
  • Master pages
  • Grid View
  • Profiles

Asp.net 3.5 includes the following as new features
  • List View control
  • Data pager control
  • Nested master pages
  • LINQ Data Source Control.
Asp.net 2.0 does not support multi targeting environment. Asp.net 3.5 Support multiple targeting option that we choose from the dropdown list whether to have visual studio 2008 build application against the asp.net 2.0, 3.0, 3.5 frameworks
There is no inbuilt support for ajax you have to explicitly download and installed the software. In asp.net 3.5 ajax is integrated into the framework, thereby making the process of building intuitive cool user interfaces easier.
It does not support silverlight It supports silverlight.
It does not provide javascript debugging. It provide javascript debugging
It does not support LINQ It support language intergrated query (LINQ)
Only source and design view Source, design and split view.