.NET Basics
Most people will know about .NET, Microsoft's architecture for future software development. Unlike previous development systems such as VB6, the source code is not compiled to pure machine code; instead, it is compiled to a Pseudo Code. The Pseudo-Code is run on top of a Common Language Run-Time, which converts the code into machine code. It is, in a way, Microsoft's attempt at copying Sun's Java but without the ability to run on any operating system except Windows. There are several Linux ports, such as Go-Mono, that have limited Microsoft approval.
The two main languages available for the .NET framework are C# and VB.NET. The latter has been eclipsed in popularity by C# because it is less wordy and faster in some people's eyes. All .NET code compiles to the same Pseudo-Code, so a program written in VB.NET can do a good job as if it was written in C#. There is no speed improvement in choosing C# over VB.NET. People's misconceptions of the speed are due to COM programs written in C++ being faster than VB6 applications, but that is not the case.
C# is based on the 'C' programming language family, which includes C++ and Java. Although Java doesn't have the letter 'C' in its name, it does have the same structure as the other family members.
In VB6, variables were just that, just variables. Now in C#, all variables are objects with methods and properties. Where in VB6 you would do
Dim intLength as integer
intLength = len(strText)
You can do instead :-
Dim intLength as integer = strText.Length
In the above example, I've shown you another ease of programming style introduced in .NET: you can define a variable and set the value in the same line. That aligns C# with the 'C' programming languages that contain that feature.
Another big change that has come about in .NET is that code is always compiled before it is run. In VB6, code could be debugged through an interpreter interface. In .NET, you can still debug, but you can't change the code midway through the stepping through and expect the code to take account of that. You would need to stop the programme and restart it. Considering how buggy VB6 used to be and occasionally crashes when you debugged through, it is a sensible option.
Error handling had an overhaul in .NET, whilst On Error Goto... construct is still supported, it is recommended that you use the new try..catch..throw mantra that C++ developers have used for years.
Tags - .NET
Last Modified : June 2023