Showing posts with label Visual Programming –1 in C#. Show all posts
Showing posts with label Visual Programming –1 in C#. Show all posts

Sunday, September 9, 2018

The .NET Framework Architecture


Common Language Specification (CLS)
Enables cross-language interoperability
Common Language Specification describes interoperability requirements
Inside CLS common type system (CTS) describe how different data types for the same constant should work together.
For example char array in C++ and Strings in C# can be used as sequence of alphabets.
CLS is what the languages must provide in order to work in the .NET Word.
This Specification is public so any one can write a language to work with .NET frame work but first to complete the CLS.
Over 15 languages  are  supported today by .Net.
C#, VB, Jscript, Visual C++ are from Microsoft, but there are  some other languages  also that use the same set of services as they came with CLS.
NET Classes (4 Areas)
ASP.NET:
ASP.NET provides the core Web infrastructure such as Web Forms development and Web Services.
Windows Forms:
User interface development on the Windows platform can be done using Windows Forms
ADO.NET:
Provide the means (functions, classes and so on..) for  data access.
Base Class Library:
Finally, the core base classes library (BCL) contains namespaces that group classes into common blocks of functionality for common and frequent use.
For example all the classes deals with files are in one namespace
Common Language Runtime (CLR)
CLR provide common runtime Environment for all .NET languages.
CLR purpose is to run and load Application compiled to Microsoft Intermediate Language (MSIL) or IL in short.
CLR manages basic services of .NET such as:
Memory management
Garbage collection
Exception Handling
Loading/Running Applications
CLR with Managed and Un-Managed code
CLR allow the applications to run the managed and unmanaged code.
Unmanaged code runs out side the CLR.
For example VB6/C++ code compiled w/o .NET
Managed code runs within the CLR and get benefits of the CLR  features( Memory management, Garbage Collection and So on).









NET Framework Base Class Library

BCL consists of classes that provide base functionality for .NET Framework
And many classes that make your life as developer easier
Library of classes used by all .NET applications
Contains large number of classes (Block of functionality, properties and events) grouped into namespaces
Each class within namespace has a unique name.
BCL’s namespaces group classes into common blocks of functionality.
For example all the classes deals with files are in one namespace i.e. System.IO
Some BCL namespaces…
System
That includes the basic data types like integer, string, time, Boolean and so on.
Some console and input/output, garbage collection and memory management functions.
System.Data
Including the classes dealing with data including ODBC, SQL server, data sources and so on.
System.IO
Have functionality about working with streams and disks i.e. moving data from one place to an other.
System.Text
Dealing about string and texts. Converts data from block of bytes to texts and so on.
System.Text.RegularExpresions
Providing some magic of string operations and matching of data.
System.Web
Provide design and run time support for web application.
System.Windows.Forms
Provides the support for using and designing the windows application and its controls.
System.Text.RegularExpresions
Providing some magic of string operations and matching of data.
System.Web
Provide design and run time support for web application.
System.Windows.Forms
Provides the support for using and designing the windows application and its controls.
System.Collections.Generic
Deals with the safe-type-caste provide conversion between data values.
If different names for the same data type are there in different language then this class ensures the .NET that actually they are the same. E.g. int in C++ is same to integer in VB.net and numeric of SQL.
System.Linq
Providing classes to link a source and enable the application to query the data.
Design for
A Simple window application  Add, Subtract, and Multiply

 




Addition Code

private void btnAdd_Click(object sender, EventArgs e)
        {
            int num1, num2, result;
            String rslt;
            num1 = Convert.ToInt32(txtNum1.Text);
            num2 = Convert.ToInt32(txtNum2.Text);
            result=num1+num2;
            rslt = result + "";
            txtResult.Text = rslt;
Subtraction Code
private void btnSub_Click(object sender, EventArgs e)
        {
            int num1, num2, result;
            String rslt;
            num1 = Convert.ToInt32(txtNum1.Text);
            num2 = Convert.ToInt32(txtNum2.Text);
            result = num1 - num2;
            rslt = result + "";
            txtResult.Text = rslt;
       }
Multiplication Code
private void btnMul_Click(object sender, EventArgs e)
        {
            int num1, num2, result;
            String rslt;
            num1 = Convert.ToInt32(txtNum1.Text);
            num2 = Convert.ToInt32(txtNum2.Text);
            result = num1 * num2;
            rslt = result + "";
            txtResult.Text = rslt;
        }





Thursday, August 30, 2018

Introduction


Introduction to C#…

Officially Microsoft define C# as  a “simple, modern and object-oriented language derived from C and C++.”
But most independent observations would change this description to “derived from C, C++ and Java.”
Because syntactically C# is very similar to C++ and Java.
As many of the key words are the same for example the same braces ({}) to block a piece of code, (;) for separation of statements from each other and the way to get the data from external source which is out of .NET Environment.
To discuss more about C# language and its associated environment, the .NET Framework, as the most important technology for developers for many years, the following should be considered.
Net Framework as a run time environment for MS Windows 2000 and onward - is a fresh start for Microsoft rather extending the existing code base again and again.
As the point will come that the extension to existing code will become more complex with a passage of time. 
The time will come that compatibility will have no value for outdated products.
Finally, caused .Net Frame Work.
.NET is designed to provide a new environment where you can develop almost any application to run on OS (windows).
While C# is a new programming language that has been designed specifically to work with .NET.
Using, C# we can create a classic window desktop application, a database access component, a component of distributed application, a dynamic web page and XML web service.
C# provides a means for you to code up any type of software or component you need to write for the windows platform.
Using, C# we can create a classic window desktop application, a database access component, a component of distributed application, a dynamic web page and XML web service.
C# provides a means for you to code up any type of software or component you need to write for the windows platform.
Need of .NET and C#…
In order to understand the significance of .NET, it is useful to remind that in past history of operating systems, although they may look quite different on the surface, but all of the window operating systems from window 3.1 (introduced in 1992) through windows server 2003 have the same familiar Windows API at their core.
As we progress to the new versions of windows, huge numbers of new functions have been added to the API, but this has been a process of evolving and extending the API rather than replacing it
Microsoft choose this evolutionary approach to software for the obvious reason that it is concerned about the backward compatibility.
Over the years a huge base of third-party software has been written for windows, and windows wouldn’t have enjoyed the success it has had if every time Microsoft introduced a new technology that broke the existing code base!
Backward compatibility is an essential feature of Windows technologies but extending the existing code has a big disadvantage.
Every time technology evolves and add new features it becomes more complicated than it was before. 
So now it is clear that in case something had to change. Microsoft could not go on forever extending the same development tools and languages, always making them more and more complex in order to satisfy the conflicting demands of keeping up with the newest hardware and maintaining backward compatibility.
There comes a point where you have to take new start with a clean line if you want a simple yet sophisticated set of languages, environment and developer tools, which make it easy for developer to write state-of-the-art software.
This fresh start is what C# and .NET are all about. Clearly .NET is a framework (An API) for programmers of different skills.
While C# is a language that has been designed from scratch to work with .NET, as will as to take advantage of all the progress and OOP principles that have taken place over the past 20+ years.
We should make it clear that the backward compatibility has not been lost in the process. Existing programs will continue to work, and .NET designed with ability to work with these programs.
Presently communication between software components on windows almost entirely takes place using COM (Component Object Module).



The .NET Framework Architecture

Common Language Specification (CLS) Enables cross-language interoperability Common Language Specification describes interoperabili...