+ 2

C# using system is needed?

Every c# code needs using system. If so, why did they make using system if we are going to type it every time? If not, are there codes you can make without using system???

10th Apr 2018, 10:24 AM
syul
syul - avatar
3 Answers
+ 7
Well first of all you need to understand the purpose of <using> in the code. When you write using System; it actually means you're going to make a reference to the library class available in the System namespace. Therefore if you want to avoid writing it, you'll need to prefix every statements that's under the System namespace like following:- System.Console.WriteLine("42"); System.Console.WriteLine("abc"); Otherwise without it the compiler will not understand the definition of Console as it's coming from nowhere. Hopefully it helps! 😉
10th Apr 2018, 1:39 PM
Zephyr Koo
Zephyr Koo - avatar
+ 2
No you don’t need using system. It just assumes that you may need the classes from system, since there are many useful ones. You can remove it if you’re not using classes such as Random.
10th Apr 2018, 11:10 AM
Ariela
Ariela - avatar
0
@Ariela The main system method i use is Console.Write Is there anyway to get an output without using system?
10th Apr 2018, 11:56 AM
syul
syul - avatar