Reputation: 311
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.
Upvotes: 3
Views: 131
Reputation: 2427
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.
Upvotes: 3