Reputation: 2163
i wanted to know as i start to make some dramatic move from using regular helpers to more and more extension methods
so they start to pile up ,
say my top main namespace is as follows :
the main namespace name is myname + last digit of year and current month
thats how i keep it organized as a helper namespace
namespace "myname212"
{
namespace DbRelated
{
some clasess & methods
}
namespace styling
{
same as usual ..
}
// .... some more categories and...then
//the extentions namespace
namespace CustomExtentions
{
// simplest ext class and its first method
public static class ToNumber
{
public static int Toint(this Textbox TbxToConvrt)
{
return Convert.ToInt32(TbxToConvrt.Text);
}
//some more of same subject
}
}
}
but what if i have a more general catefory that has it own sub category logocally
namespace Extentions
{
public static class MainCategory
{
public static class SubCat1
{
public static some_method();
}
public static class SubCat2
{
public static some_method();
}
}
}
the a hierarchical stracture above will not work .
so is it true that if i'd like to build more categories i could only do it via
nested namespaces
instead of nested classes
?
is this what you do ?
Upvotes: 2
Views: 1131
Reputation: 100348
You can nest namespaces instead:
namespace My.Nested.Namespace.So.Far
{
public static class BlaExtensions
{
}
}
or even:
namespace My.Nested.Namespace
{
public static class FooExtensions
{
}
namespace So.Far
{
public static class BlaExtensions
{
}
}
}
Upvotes: 4