RingDotNetfor Ring

.NET for Ring programmers

What .NET is and the words you will meet when you use it. Read this once; come back when a word is not clear.

What is .NET?#

.NET is a large collection of ready-made code from Microsoft, plus the program that runs it. You do not write that code — you use it. Instead of writing your own function to read a file, compress a folder, hash a password or talk to a web server, you ask .NET to do it. RingDotNet lets a Ring program ask.

Two things make up .NET:

PartWhat it isAnalogy
The runtimeThe engine that loads and runs .NET code. RingDotNet starts it inside your Ring program.The Ring virtual machine
The class libraryThousands of classes: text, numbers, files, networking, windows, databases...Ring's built-in functions, but much larger
Ring
load "dotnet.ring"

using { "System" }
? new Environment().Version.ToString()   # the runtime that is running inside your Ring program
Output
9.0.15

Classes and objects#

Almost everything in .NET is an object. An object has data and abilities; the class is the description that the objects are made from — like a recipe and the cakes baked from it.

Ring
using { "System.Text" }

oText = new StringBuilder("Hello")      # create an object of the class StringBuilder

You already know this from Ring: Ring has classes and objects too (class, new). The difference is that these classes were written by Microsoft, in C#, and live in .NET.

Properties, methods and events#

An object has three kinds of members:

MemberWhat it isIn RingExample
Propertysomething the object knows (a value you read or change)oObject.Name and oObject.Name = valueoForm.Text = "Hello"
Methodsomething the object can dooObject.Name(arguments)oText.Append("!")
Eventsomething that happens, to which you reactoObject.setNameEvent("code")oButton.setClickEvent("clicked()")

Static members: no object needed#

Some classes are just a toolbox of functions. Their members are static: you call them on the class, without creating an object. Math is the classic example: you never create "a math".

Ring
using { "System" }
? new Math().Max(3,9)       # a static method (Ring creates a harmless helper object to call it)
? new Math().PI             # a static property

In the class reference a static member is marked static.

Namespaces and assemblies#

.NET has thousands of classes, so they are organized:

In Ring you bring a namespace in with using:

Ring
using {
	"System.IO"
	"System.Text"
}

After that the classes of that namespace are available by their short name: File, Path, StringBuilder.

Value types: structs and enums#

Most types are classes. Two kinds of types are special:

null#

null means "no object". A method that finds nothing may return null. An object that you got from .NET can be asked oObject.isNull(), and dnIsNull(value) asks it of any value.

Exceptions#

When something goes wrong — the file does not exist, the text is not a number — .NET raises an exception. In Ring an exception is a normal Ring error, and you catch it with try ... catch. The tutorial When things go wrong explains this.

Generics and collections#

A collection holds many items. .NET has a list (List), a dictionary (Dictionary), a set, a queue and a stack. They are generic: the same class works for any type of item (List<string>, List<int>). RingDotNet gives you ready names for the common ones: StringList, NumberList, StringDictionary... The tutorial Collections and LINQ shows them.

The words around .NET#

WordMeaning
C#The main language that .NET code is written in. You do not need to learn it to use .NET from Ring, but the documentation shows C# examples.
SDKThe software development kit: the compiler and tools for writing .NET programs. You only need it to build C# code (the tutorial A library written in C#) and to get NuGet packages (the tutorial A NuGet package).
RuntimeWhat is needed to run .NET programs. RingDotNet needs the runtime (and the desktop or ASP.NET runtime for windows and web).
NuGetThe package store of .NET. A NuGet package is a set of .dll files that you can wrap and use: A NuGet package.
BCLThe base class library: the part of .NET that every program has (System, System.IO, System.Text...).
Windows Forms / WPFTwo ways to build windows. The tutorial Your first window and WPF.
ASP.NET CoreThe web framework. The tutorial A web service with a database.
Entity FrameworkThe database library. The tutorial Databases step by step.

How Ring and .NET meet#

Ring and .NET are two different systems. RingDotNet is the bridge between them:

Read How it works when you want the details.

Next#

Reading the .NET documentation shows how to find a class on Microsoft Learn and use it from Ring.

RingDotNet — use .NET classes and methods from Ring programs. Screenshots and output on these pages come from the real samples.