.NET

From Computernewb Wiki
Jump to navigation Jump to search

.NET is an open-source software framework primarily developed by Microsoft. You can interact with it through three programming languages (C#, F#, and Visual Basic). There are two different versions of .NET: .NET Framework and .NET, formerly called .NET Core. .NET Framework allows for Windows desktop applications, while .NET offers a universal way to develop non-GUI programs on Microsoft Windows, macOS, and Linux.

C#

C# is the most popular language used for the .NET framework. With many similarities in its syntax between it, Java, and C++, it's one of the easiest ways to get into the .NET environment. The following code is a simple demonstration of the language:

Language: C#
// C# demo code.

using System;

namespace DemoProgram {
    class Program {
        static void Main(string[] args) {
            var netLanguages = new List<string>{"C#", "F#", "Visual Basic"};
            int index = 1; // Set to 1 because the C# count property starts at 1 instead of 0.
            Console.Write("The three main languages used with .NET are ");
            foreach(var language in netLanguages) {
                if(index == netLanguages.Count) {
                    Console.Write($"and {language}.\n");
                } else {
                    Console.Write($"{language}, ");
                }
                index++;
            }
        }
    }
}


F#

Being a programming language that many people have not heard of, F# isn't used as often as C#. It has a syntax that looks closer to Python's than Java's, which could make it easier to learn for people who program in Python.

Language: F#
My eyes, it burns!
// F# demo code.

open System

[<EntryPoint>]
let main argv =
    let netLanguages = ["C#"; "F#"; "Visual Basic"]
    let index = 1
    Console.Write("The three main languages used with .NET are ")
    for language in netLanguages do
        if index = netLanguages.Length then
            Console.Write("and {0}.\n", language)
        else
            Console.Write("{0}, ", language)
        index <- index + 1
    0 // Return with exit code 0.


Visual Basic

Visual Basic, despite most likely being easier to read for non-programmers, is probably the least used .NET programming language. Its odd syntax was likely one of the main reasons that this language never took off. Another reason could be that this was a deriative of BASIC.

Language: Visual Basic
' Visual Basic demo code.

Imports System

Module Program
    Sub Main(args As String())
        Dim netLanguages As New List(Of String)
        netLanguages.Add("C#")
        netLanguages.Add("F#")
        netLanguages.Add("Visual Basic")
        Dim index As Integer = 1
        Console.Write("The three main languages used with .NET are ")
        For Each language As String In netLanguages
            If index = netLanguages.Count Then
                Console.Write($"and {language}.{vbCrLf}")
            Else
                Console.Write($"{language}, ")
            End If
            index = index + 1
        Next
    End Sub
End Module