Reading the .NET documentation
Everything .NET can do is documented on Microsoft Learn. This page shows how to find a class there and turn what you read into Ring code.
Where the documentation is#
The official reference is Microsoft Learn → .NET API browser (search for "learn.microsoft.com dotnet api"). Every class has a page. For example the page of System.Text.StringBuilder lists its constructors, properties, methods and events, with a short description and a C# example for each.
RingDotNet also has its own class reference with the same information written for Ring: every member shows how to call it from Ring. Use it first; use Microsoft Learn when you want the long explanation.
How to find the class you need#
- Think about the job: "read a file" → files; "split a date" → dates; "send a web request" → HTTP.
- Search by words in the search box of this site (press
/) or on Microsoft Learn:read text file C#. The answer almost always names a class:File,StreamReader... - Look at the namespace shown on the page title:
System.IO.Filemeans the namespace isSystem.IO. - Check that the class is wrapped: open
api/System.IO.htmlin the class reference, or search the class name.
Reading a class page#
A Microsoft page for a method looks like this (shortened):
File.ReadAllText(String) → String
File.ReadAllText(String, Encoding) → Stringand a C# example:
string text = File.ReadAllText(@"C:\notes.txt");
Console.WriteLine(text);From C# to Ring#
| In C# | In Ring |
|---|---|
using System.IO; | using { "System.IO" } |
var f = new FileInfo(path); | oFile = new FileInfo(cPath) |
File.ReadAllText(path) | new File().ReadAllText(cPath) (a static method is called on new File()) |
text.Length (a property) | oText.Length |
list.Add("x") (a method) | oList.Add("x") |
button.Click += handler; (an event) | oButton.setClickEvent("handler()") |
DayOfWeek.Monday (an enum) | "Monday" (a text) |
Math.Round(x, 2) | new Math().Round([ :value = x, :digits = 2 ]) |
int.TryParse(s, out n) (an out parameter) | aResult = new Int32().TryParse(cText) → [worked, number] |
null (a method returned it) | oObject.isNull() |
new DateTime(2024, 12, 25) | new DateTime(2024,12,25) |
new Point { X = 1, Y = 2 } | new Point(1,2) |
new TimeSpan(1, 2, 3) (a constructor with several forms) | new TimeSpan().@New([ :hours = 1, :minutes = 2, :seconds = 3 ]) or dnNew("TimeSpan",[1,2,3]) |
random.Next(1, 7) (a name that is a Ring word) | oRandom.@Next([ :minValue = 1, :maxValue = 7 ]) (the name starts with @) |
table.AddColumn("Name") (an extension method) | oTable.AddColumn("Name") (the Ring class of the type has it) |
Overloads: one name, different parameters#
C# lets the same method name have several versions (overloads) with different parameters. A Ring method has one parameter list, and RingDotNet maps the overloads like this:
- a name with several forms becomes one method that takes one value:
NULLfor the form without parameters, a value for the form with one parameter, and - a list of named arguments for the others:
new Math().Round([ :value = 3.14159, :digits = 2 ]). The names are the parameter names that you read in the documentation. To pass several values in order,oObject.callMethod("Name",[a, b])chooses the overload that fits them, as C# does.
The class reference shows, for every method, the Ring calls next to the .NET overloads, so you never have to guess. Core concepts lists the rules.
A complete example#
Task: "get the file name from a path". Search → Path.GetFileName in System.IO.
The documentation says: public static string GetFileName(string path). It is static, so on a new Path() object, and it takes one text:
using { "System.IO" }
oPath = new Path()
? oPath.GetFileName("c:/work/report.txt") # report.txtWhen a class is not wrapped#
Everything in the base library and in Windows Forms, WPF, ASP.NET and Entity Framework is wrapped. Other packages can be wrapped in one command: Your own assemblies and the lesson A NuGet package. Without wrapping, a few generic functions still reach any .NET type; they are explained in Core concepts and used in the later chapters of the tutorials.
Next#
Start the first lesson: A first look.