Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redundancy in Using Directives

Tags:

c#

.net

I'm new to ASP.NET development and there is something I quite don't grasp regarding using directives...

using System;
using System.Data;
using System.Data.SqlClient;

In the above code example, I am curious as to why we must explicitly list System.Data and System.Data.SqlClient when they are already included in the first statement using System;. It seems redundant that we must specify namespaces that are included in parent namespaces. I know there is probably a very simple explanation to this question, but I've been unable to find it with my search.

like image 450
Shandy Avatar asked Dec 11 '25 23:12

Shandy


1 Answers

using System;

doesn't include the namespace System.Data. Those are separate namespaces. Thus, you need both if you intend to use classes defined in both of those namespaces.

like image 177
Fang Avatar answered Dec 13 '25 12:12

Fang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!