Writing
your first c sharp program:
In this article we will go
through some of the basics steps to get familiar with most of the things in c
sharp programs. This article explains the structure of the c sharp program,
how to compile and execute the c# program by using the command prompt and
also it introduces you how to use the visual studio IDE to execute the
projects. Let's Start With a simple 'Hello World Program'.
|
Conditional
Statements and Loop constructs
Conditional statements
controls the sequence of statements, depending on the condition
|
Arrrays in Csharp
Arrays provide the same functionality and they work similarly to how
the arrays work in other programming languages. However, there are few things
which you might keep in mind while working with arrays
|
Constructors
A constructor that takes no parameters is called a default constructor.
When a class is initiated default constructor is called which provides
default values to different data members of the class.
|
Static
Polymorphism:
Using the same name for two or
more functions is called function overloading. Each redefinition of a
function must use different types of parameters, sequence of parameters, or a
number of parameters. The type , seqeuence , or number of parameters for a function is called function signature.
Same is briefly explained as follows.
|
Dynamic
Polymorphism: Abstract Classes and Interfaces
An abstract class is a special kind
of class that cannot be instantiated. So the question is why we need a class
that cannot be instantiated? An abstract
class is only to be sub-classed (inherited from). In other words, it only
allows other classes to inherit from it
but cannot be instantiated. The advantage is that it enforces certain
hierarchies for all the sub classes
|
Sealed,Partial Classes and Inheritance |
Working
with Collection classes C Sharp
Dot net Base Class library provides number of collection class to work
with. Generally collection classes are used to group related objects. The
collection classes are designed in order to overcome the limitations of the
arrays. Most of the collections classes have methods to add, delete, find,
sort, reverse and many more.
|
Working
with stack
Stack is another flexible collection class available in
System.Collections namespace. Stack size increases dynamically as we add
elements to the stack. In Stack the elements are organized in Last In First
Out (LIFO) format.
|
Working
with Queue:
Queue class which is available in System.Collections namespace,
represents First – in – First Out(FIFO).
Collections of objects. Queue size increases dynamically as we add
elements to it. Queue has two general methods Enqueue and Dequeue by using
which we can maintain the elements in the collection.
|
Working
with Hashtable
HashTable class is one of the effective collection classes available in
the Sytsem.Collections namespace. Out of all available classes ArrayList and
Hashtable are used more frequently. Apart from all the collection classes
Hastable has got one additional feature, i.e., it allows to store the element
with a unique key value.
|
Working
with Generics
Most of the classes of System.Collection hold the element as object
type. Generics are more specialized collections classes which are used to
group the specified type of elements. Generics are type-safe container
classes that can only operate on a particular type of data.
System.Collections.Generics namespace is introduced in the .net 2.0 version.
Most commonly used collections classes are ArrayList and Hashtable and their
equivalent Generic types are List and Dictionary.
|
File I/O
Microsoft .NET framework
provides the most efficient types to work with input and output operations.
In this article we will learn how to use those built in types and their
methods to perform our tasks. Initially we begin with reading and writing
file streams.
|
WindowsFileSystem
The class provides numerous instance methods to move, copy, create and
enumerate through directories and sub directories.
|
Reading
and Writing into files
The filestream class provides the basic functionality to open file
streams for reading and writing.
|
CSharp
Subscribe to:
Posts (Atom)