I'm working on this
Abstract and Interface thing in C#, if you are still new on this, or not yet heard about it, try to make some research, write down some notes and add some practical questions. My Goal is to understand this fully and how to deliver it to anyone that can understand its application.
I find it very important topic for beginners, that instead of studying how to declare integer, arrays, or how to use loop, One should start writing abstract and interfaces. Understand it! and find it how abstract and interface being use .NET environment.
for example:
in your Windows file you will find
"mscorlib.dll" which is one of the DLL use in
"system" namespace. like the one you use to write at the beginning of the program eg.
"using System;"
consider this program:
using System;
using System.IO;
class Program
{
static void Main()
{
string line;
using (StreamReader reader = new StreamReader("file.txt"))
{
line = reader.ReadLine();
}
Console.WriteLine(line);
}
}
I'm sure you know what program is doing, but
what is StreamReader?
is it a product of Abstract and Interfaces? the answer is
YES(both)! In fact every line of it, went thru various
ABSTRACT and
INTERFACE definitions.
the StreamReader is a derived from the abstract base class Textreader, The StreamReader class is designed for reading character or string input from a file. This class contains methods to read single characters, blocks of characters, lines of characters, or even the whole file into a single string variable.
You might be asking now, where to find the the derived statement of Textreader? is it an abstract or interface? from MSDN definitions:
public abstract class TextReader : MarshalByRefObject, IDisposable
public abstract class MarshalByRefObject
public interface IDisposable
that's it!
TextReader is an Abstract, derived from another both Abstract and Interface class, which again use in StreamReader.
all of them is under the "system" namespace which is written inside
mscorlib.dll. If it happens that you delete the file, you will get compilation error:
Code:
error CS0025: Standard library file 'mscorlib.dll' could not be found
OK! cut...! hehehe, so much for that for now.
If you have some valuable materials, programs, insights, knowledge, questions or whatsoever you want to talk or share just PM me. I will be making some handouts with exercises and sample running program. All knowledge, Idea, graphics etc... will be given some credits.
The Material may includes the following:
1. Overview of Abstract and Interface.
2. Abstract vs Interface.
3. When to use Abstract and when to use Interface.
4. Various example of Abstract and Interface.
5. Problem Solving using Abstract, using Interfaces and using Both Abstract and Interface.
Problems will be taken out from one of my application, or I will get some open source program written in python/c++/vb and convert it to C#.NET version.
Programs are all console based. NO GUI this time.
Its about time to share some knowledge, ask some knowledge, make use of the knowledge you got.
cheers...