Wednesday, December 10, 2008

Object As A Return Value

if you want to return structure or any object as a return value

use the following format in class file

Public Class ClassName

Public Structure StructName
'variables
End Structure

Public Function MethodName(....) As StructName

Dim structObject as StructName

Return structObject
End Sub

End Class


Then use the method in your class just like this


Dim retValues As New ClassName.StructName
Dim obj As New ClassName
retValues = obj .MethodName(....)

Monday, June 9, 2008

How To Use A Windows Control In An ASP.NET Page

The step by step way to create windows controls and use it in an ASP.NET page

1:create a new project Windows Control Libray
2:build and execute
3:create the key pair using SDK command promptsn -k ssokeypair.snksn -p ssokeypair.snk ssopublic.snk
4:import keypair to your project
5:right click on the project->properites->signing->check sign the assembly->choose our keepair
6:Set ComVisible property to "true" in assemblyInfo.cs file.
7:go to SDK command prompt register the controlregasm [path of control] /codebase
8:use the registered control in your asp.net project or any other project
9:get classid of the object from registry editor
10: format of object tag : object id="MyControl.UserControl1" classid="clsid:125A8E3F-FE89-3133-B956-DD041D7BED9E"

Friday, May 16, 2008

When to use Arrays and Collections

A quick overview of when to use Arrays and Collections

Arrays :
When :You know the required array size at design time.

ArrayList:
When :You do not know the required array size at design time.

Hashtable:
When :To store Large amounts of data For example, product catalogues where a product ID is the key.

HybridDictionary:
When : For storing data when the number of records is expected to be low most of the time, with occasional increases in size. If you are sure that the size of collection will be always high or always low, you should choose Hashtable and ListDictionary respectively. This avoids the extra cost of the HybridDictionary, which acts as a wrapper around both these collections.

ListDictionary:
When :To store small amounts of data (fewer than 10 items)

NameValueCollection:
When : To store strings of key/value pairs in a pre-sorted order. Note that you can also have multiple entries with the same key.
for example:if you need to display subjects registered by students in a particular class because it can store the data in alphabetical order of student names.

Queue:
when :You need to access data sequentially, based on priority. For example, an application that scans the waiting list of plane

SortedList:
When :The collection can be used where the data is mostly static and only a few records need to be added or updated over a period of time, For Frequently updated data use ArrayList with Sort

Stack:
When: you need to process items in a last–in, first-out manner. For example, an application that needs to monitor the 10 most recent users visiting a Web site over a period of time.

StringCollection:
When : store string data that changes frequently and needs to be retrieved in large chunks.

StringDictionary:
When : store static string data needs to be retrieved in large chunks.

The above details I posted for getting a quick overview, Read this msdn article for detailed design guidelines

References: