using static to include static methods - CSharp Custom Type

CSharp examples for Custom Type:static

Description

using static to include static methods

Demo Code

using System;//from   ww  w  . jav a 2 s .  c  o m
using static System.Console;
class Program
{
   static void Main(string[] args)
   {
      ForegroundColor = (ConsoleColor) Enum.Parse(typeof(ConsoleColor), "Red", true);
      BackgroundColor = (ConsoleColor) Enum.Parse(typeof(ConsoleColor), "Black", true);
      try
      {
         WindowWidth = int.Parse("123");
         WindowHeight = int.Parse("1234");
      }
      catch (PlatformNotSupportedException)
      {
         WriteLine("The current platform does not support changing the size of a console window.");
      }
      WriteLine($"There are {args.Length} arguments.");
      foreach (string arg in args)
      {
         WriteLine(arg);
      }
   }
}

Result


Related Tutorials