+92 332 4229 857 99ProjectIdeas@Gmail.com

"using" Keyword Magic (C#.net)



"using" can be used to change the alias of namespaces. see the code below.

Code



using Terminal = System.Console;

public class TestUsing
    {
      
        public static void Main(string[] args)
        {
            // Defining your own name "Terminal" of "System.Console Class"

            Terminal.WriteLine("I am Dangerous");

        }
    }


 Or,



using FileWriting = System.IO.TextWriter;

public class TestUsing
    {
      
        public static void Main(string[] args)
        {

       // Defining your own name "FileWriting" of "System.IO.TextWriter Class"

            FileWriting fw = File.CreateText(@"D:\abc.txt");

            fw.WriteLine("Hello World!!!");

            fw.Flush();
        }
    }

0 comments: