No, really - you should.
try.dot.net lets you write C# code easily in your browser and run it to see live results. I've found this very useful on a number of occasions already, for example when wondering about the behavior of path or URL classes in some edge conditions.
Here are some of the reasons why it's quickly becoming my go-to scratchpad.
So, the next time you want to play with regular expression results, or try out various type formatting masks, or look at some specific values serializes, look no further.
For example, remember the good old DataSet class? It's still there, working just fine. If you want to see how it serialized, just type this in and feel young again.
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Data;
public class Program
{
public static void Main()
{
DataSet ds = new DataSet("myds");
DataTable dt = ds.Tables.Add("mytable");
DataColumn dc = dt.Columns.Add("mycol", typeof(string));
DataRow dr = dt.Rows.Add("my first row");
MemoryStream stream = new MemoryStream();
ds.WriteXml(stream);
stream.Position = 0;
StreamReader reader = new StreamReader(stream);
string dsXml = reader.ReadToEnd();
Console.WriteLine($"bytes for XML: {stream.Length}");
Console.WriteLine(dsXml);
}
}
Happy coding!
Tags: dotnet