Wednesday, February 24, 2010

.NET Framework Value Types and Reference Types

Value Types:
The .NET Framework includes a large number of built-in types that you can use directly or use to build your own custom types.

Value types directly contain their data, offering excellent performance. However, value types are limited to types that store very small pieces of data. In the .NET Framework, all value types are 16 bytes or shorter.

You can create user-defined types that store multiple values and methods. In object-oriented development environments, a large portion of your application logic will be stored in user-defined types.

Enumerations improve code readability by providing symbols for a set of values.

Reference Types:
Reference types contain the address of data rather than the actual data.

When you copy a value type, a second copy of the value is created. When you copy a reference type, only the pointer is copied. Therefore, if you copy a reference type and then modify the copy, both the copy and the original variables are changed.

The .NET Framework includes a large number of built-in reference types that you can use directly or use to build your own custom types.

Strings are immutable; use the StringBuilder class to create a string dynamically.

Use streams to read from and write to files, memory, and the network.

Use the Catch clause within Try blocks to filter exceptions by type. Close and dispose of nonmemory resources in the Finally clause of a Try block.

Friday, February 12, 2010

VS2008 Win Form - Calling Crystal report

Dim objRPT As New rptmatchstats

Dim objfrmRPTViewer As New frmreportviewer

'Note: The form has to be shown first, other wise report parameters are prompted
objfrmRPTViewer.CRPTViewer.Visible = False
objfrmRPTViewer.MdiParent = Me.MdiParent
objfrmRPTViewer.WindowState = FormWindowState.Maximized
objfrmRPTViewer.Show()

objRPT.PrintOptions.PaperSize = CrystalDecisions.[Shared].PaperSize.PaperLetter

oConn.applyLogonInfo(objRPT)

'Set Parameters
oConn.assignParameterValueToReport(objRPT, "@id", 10)

objfrmRPTViewer.CRPTViewer.ReportSource = objRPT

objfrmRPTViewer.CRPTViewer.ParameterFieldInfo.Clear()

objfrmRPTViewer.CRPTViewer.ParameterFieldInfo = objRPT.ParameterFields

objfrmRPTViewer.CRPTViewer.Visible = True