.Net Basic

This blogs gives introduction to C#.NET programming for beginners. This blogs assumes that you have no programming experience whatsoever. It's a lot easier than you think, and can be a very rewarding hobby!after Refer this blog

08 July 2008

events

Event - An action that an object does. When something happens, we say an event has happened. For example, when a button is clicked, we say it is the click( ) event. When a mouse hovers on an image, we say the mouseover( ) event has taken place.

property in C#.net

Property - A property is a thing that describes the features of an object. A property is a piece of data contained within a class that has an exposed interface for reading/writing. Looking at this definition, we might think we could declare a public variable in a class and call it a property. While this assumption is somewhat valid, the real technical term for a public variable in a class is a field. The main difference between a field and a property is in the inclusion of an interface.

We make use of Get and Set keywords while working with properties. We prefix the variables used within this code block with an underscore. Value is a keyword, that holds the value which is being retrieved or set.ss="a">

Private _Color As String
Public Property Color()
Get
Return _Color
End Get
Set(ByVal Value)
_Color = Value
End Set
End Property

Overriding and Shadowing

Both Overriding and Shadowing are ways to alter the behaviour of members of a base class. Shadowing is a VB.NET concept. In C#, this concept is called Hiding, though there is a difference between the two.

When we do shadowing, we provide a new implementation to the base class member without overriding it. We may shadow a base class member in a derived class, by using the keyword shadows. The access level, return type, and the signature (means the datatypes of the arguments passed & the order of the types) of the derived class members which are shadowed, may differ from the base class.

In C#, we may achieve shadowing using the keyword new. However, when Hiding in C#, the access level, the signature, return type of the derived class must be same as the base class.

Overriding is the concept of providing a new implementation of derived class member as compared to its based class. In VB.NET, we do overriding using the overrides keyword, while in C#, overriding is achieved using the override keyword. For a class member to be overridable, we use the keyword virtual while defining it (in C#), and we use the keyword overridable (in VB.NET), though if we leave out specifying the overridable keyword, the member is overridable by default.

ExecuteScalar and ExecuteNonQuery

ExecuteScalar - Returns only one value after execution of the query. It returns the first field in the first row. This is very light-weight and is perfect when all your query asks for is one item. This would be excellent for receiving a count of records (Select Count(*)) in an sql statement, or for any query where only one specific field in one column is required.

ExecuteNonQuery - This method returns no data at all. It is used majorly with Inserts and Updates of tables. It is used for execution of DML commands.

Labels:

access specifiers

The main purpose of using access specifiers is to provide security to the applications. The availability (scope) of the member objects of a class may be controlled using access specifiers.

1. PUBLIC
As the name specifies, it can be accessed from anywhere. If a member of a class is defined as public then it can be accessed anywhere in the class as well as outside the class. This means that objects can access and modify public fields, properties, methods.

2. PRIVATE
As the name suggests, it can't be accessed outside the class. Its the private property of the class and can be accessed only by the members of the class.

3. FRIEND/INTERNAL
Friend & Internal mean the same. Friend is used in VB.NET. Internal is used in C#. Friends can be accessed by all classes within an assembly but not from outside the assembly.

4. PROTECTED
Protected variables can be used within the class as well as the classes that inherites this class.

5. PROTECTED FRIEND/PROTECTED INTERNAL
The Protected Friend can be accessed by Members of the Assembly or the inheriting class, and ofcourse, within the class itself.

6. DEFAULT
A Default property is a single property of a class that can be set as the default. This allows developers that use your class to work more easily with your default property because they do not need to make a direct reference to the property. Default properties cannot be initialized as Shared/Static or Private and all must be accepted at least on argument or parameter. Default properties do not promote good code readability, so use this option sparingly.

Labels: , , , , ,

DLL and EXE

In .NET, an assembly may become a DLL or an EXE. Yet, there is a major underlying difference between the two.

An EXE is an executable file, that may run on its own. Its independent. Where as a DLL is a Dynamic Link Library, that binds to an exe, or another DLL at runtime.

A DLL has an exposed interface, through which members of the assembly may be accessed by those objects that require it.

A DLL runs in tandem with the application space in memory, as the application references it. Whereas an EXE is independent, and runs as an independent process.

Labels:

ADO and ADO.NET

The old ADO (ActiveX Data Object) has evolved to ADO.NET in the .NET Framework. The ADO.NET object is a lightweight object. The ADO Recordset was a huge object in ADO. It provided the ability to support multiple types of cursors. It provided fast lightweight "firehose"

ADO.NET breaks the functionality of the ADO object to multiple classes, thereby allowing a focused approach to developing code. The ADO.NET DataReader is equivalent to the "firehose" cursor. The DataSet is a disconnected cache with tracking and control binding functionality. The DataAdapter provides the ability to completely customize how the central data store is updated with the changes to a DataSet. cursor and also supported a disconnected client-side cursor that supported tracking, optimistic locking, and automatic batch updates of a central database. However, all of this functionality was difficult to customize.

Acronyms in .NET

ADO - ActiveX Data Object - Microsoft ActiveX Data Objects (ADO) is a collection of Component Object Model objects for accessing different types of data sources.

AJAX - Asynchronouse Javascript and XML - Ajax is a web development technology used for creating interactive web pages with fast data rendering by enabling partial postbacks on a web page (That means a section of the web page is rendered again, instead of the complete web page. This is achieved using Javascript, XML, JSON (Javascript Notation Language) and the XMLHttpRequest object in javascript.

ASP - Active Server Pages - Microsoft's Server side script engine for creating dynamic web page.

C# - C Sharp - Microsoft Visual C# is an object oriented programming language based on the .NET Framework. It includes features of powerful languages like C++, Java, Delphi and Visual Basic.

CAO - Client Activated Object - Objects created on the server upon the client's request. This is used in Remoting.

CCW - COM Callable Wrapper - This component is used when a .NET component needs to be used in COM.

CIL - Common Intermediate Language - Its actually a low level human readable language implementation of CLI. All .NET-aware languages compile the source oode to an intermediate language called Common Intermediate Language using the language specific compiler.

CLI - Common Language Infrastructure - This is a subset of CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform.

CLR - Common Language Runtime - It is the main runtime machine of the Microsoft .NET Framework. It includes the implementation of CLI. The CLR runs code in the form of bytes, called as bytecode and this is termed MSIL in .NET.

CLS - Common Language Specification - A type that is CLS compliant, may be used across any .NET language. CLS is a set of language rules that defines language standards for a .NET language and types declared in it. While declaring a new type, if we make use of the [CLSCompliant] attribute, the type is forced to conform to the rules of CLS.

COFF - Common Object File Format - It is a specification format for executables.

COM - Component Object Model - reusable software components. The tribe of COM components includes COM+, Distributed COM (DCOM) and ActiveX® Controls.

CSC.exe - C Sharp Compiler utility

CTS - Common Type System - It is at the core of .NET Framework's cross-language integration, type safety, and high-performance code execution. It defines a common set of types that can be used with many different language syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.

DBMS - Database Management System - a software application used for management of databases.

DISCO - Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL.

DLL - Dynamic Link Library - a shared reusable library, that exposes an interface of usable methods within it.

DOM - Document Object Model - is a language independent technology that permits scripts to dynamically updated contents of a document (a web page is also a document).

ECMA - European Computer Manufacturer's Association - Is an internation organisation for computer standards.

GC - Garbage Collector - an automatic memory management system through which objects that are not referenced are cleared up from the memory.

GDI - Graphical Device Interface - is a component in Windows based systems, that performs the activity of representing graphical objects and outputting them to output devices.

GAC - Global Assembly Cache - Is a central repository of reusable libraries in the .NET environment.

GUI - Graphic User Interface - a type of computer interface through which user's may interact with the Computer using different types of input & output devices with a graphical interface.

GUID - Globally Unique Identifier - is a unique reference number used in applications to refer an object.

HTTP - Hyper Text Transfer Protocol - is a communication protocol used to transfer information in the internet. HTTP is a request-response protocol between servers and clients.

IDE - Integrated Development Environment - is a development environment with source code editor with a compiler(or interpretor), debugging tools, designer, solution explorer, property window, object explorer etc.

IDL - Interface Definition Language - is a language for defining software components interface.

ILDASM - Intermediate Language Disassembler - The contents of an assembly may be viewed using the ILDASM utility, that comes with the .NET SDK or the Visual Studio.NET. The ildasm.exe tool may also be used in the command line compiler.

IIS - Internet Information Server - Is a server that provides services to websites and even hosts websites.

IL - Intermediate Language - is the compiled form of the .NET language source code. When .NET source code is compiled by the language specific compiler (say we compile C# code using csc.exe), it is compiled to a .NET binary, which is platform independent, and is called Intermediate Language code. The .NET binary also comprises of metadata.

JIT - Just in Time (Jitter) - is a technology for boosting the runtime performance of a system. It converts during runtime, code from one format into another, just like IL into native machine code. Note that JIT compilation is processor specific. Say a processor is X86 based, then the JIT compilation will be for this type of processor.

MBR - MarshallByReference - The caller recieves a proxy to the remote object.

MBV - MarshallByValue - The caller recieves a copy of the object in its own application domain.

MDI - Multiple Document Interface - A window that resides under a single parent window.

MSIL - Microsoft Intermediate Language - now called CIL.

Orcas - Codename for Visual Studio 2008

PE - Portable Executable - an exe format file that is portable.

RAD - Rapid Application Development

RCW - Runtime Callable Wrapper - This component is used when a .NET needs to use a COM component.

SAX - Simple API for XML - It is a serial access parser API for XML. The parser is event driven and the event gets triggered when an XML feature is encountered.

SDK - Software Development Kit

SMTP - Simple Mail Transfer Protocol - a text based protocol for sending mails.

SN.exe - Strong Name Utility - a tool to make strong named assemblies.

SQL - Structured Query Language - a language for management of data in a relational structure.

SOAP - Simple Object Access Protocol - a protocol used for exchange of xml based messages across networks.

TCP - Transmission Control Protocol - data exchange protocol across networks using streamed sockets.

UI - User Interface

URI - Uniform Resource Identifier

URL - Uniform Resource Locator

UDDI - Universal Description, Discovery and Integration - it is a platform independent business registration across the internet.

WAP - Wireless Access Protocol - a protocol that enables access to the internet from mobile phones and PDAs.

WC - Windows Cardspace - Part of .NET 3.0 framework, that enables users to secure and store digital identities of a person, and a provision to a unified interface for choosing the identity for a particular transaction, like logging in to a website.

WCF - Windows Communication Foundation - Part of .NET 3.0 framework, that enables communication between applications across machines.

WF - Windows Workflow Foundation - Part of .NET 3.0 framework, used for defining, execution and management of reusable workflows.

WKO - Well Known Object - These are MBR types whose lifetime is controlled by the server's application domain.

WPF - Windows Presentation Foundation - Part of .NET 3.0 framework, is the graphical subsystem of the .NET 3.0 framework.

WSDL - Web Services Description Language - is an XML based language for describing web services.

WML - Wireless Markup Language - is a content format for those devices that use Wireless Application Protocol.

VB.NET - Visual Basic .NET - .NET based language. Its the .NET implementation of VB6, the most widely used language in the world.

VBC.exe - VB.NET Compiler

VES - Virtual Execution System - It provides the environment for execution of managed code. It provides direct support for a set of built in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model. To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.

VS - Visual Studio

VSS - Visual Source Safe - An IDE by Microsoft, to maintain source code versions and security.

VSTS - Visual Studio Team Suite - Visual Studio Team System - it is an extended version of Visual Studio .NET. It has a set of collaboration and development tools for software development process.

XML - Extensible Markup Language - is a general purpose well formed markup language.