Tutorial by Examples

using System; using BasicStuff = System; using Sayer = System.Console; using static System.Console; //From C# 6 class Program { public static void Main() { System.Console.WriteLine("Ignoring usings and specifying full type name"); Console.WriteLine(&quot...
using System.Text; //allows you to access classes within this namespace such as StringBuilder //without prefixing them with the namespace. i.e: //... var sb = new StringBuilder(); //instead of var sb = new System.Text.StringBuilder();
using st = System.Text; //allows you to access classes within this namespace such as StringBuilder //prefixing them with only the defined alias and not the full namespace. i.e: //... var sb = new st.StringBuilder(); //instead of var sb = new System.Text.StringBuilder();
6.0 Allows you to import a specific type and use the type's static members without qualifying them with the type name. This shows an example using static methods: using static System.Console; // ... string GetName() { WriteLine("Enter your name."); return ReadLine(); } ...
If you are using multiple namespaces that may have same-name classes(such as System.Random and UnityEngine.Random), you can use an alias to specify that Random comes from one or the other without having to use the entire namespace in the call. For instance: using UnityEngine; using System; Ran...
You can use using in order to set an alias for a namespace or type. More detail can be found in here. Syntax: using <identifier> = <namespace-or-type-name>; Example: using NewType = Dictionary<string, Dictionary<string,int>>; NewType multiDictionary = new NewType(); /...

Page 1 of 1