Thursday, April 19, 2007

namespace in .net

1-C# contains many predefined classes that are grouped into namespaces.

2-Collectively we refer to this preexisting code as the Framework Class Library.

3-The actual code for the classes is located in .dll files called assemblies.

يعنى نفهم من كده إن النييم سبييس عامل زى الفولدرز بينظملك الكود بتاعك وكمان لييه فايده كبيررة وهو إنه لما تستخدم مكاتب برمجية من الخارج
classes
لو إسمها متشابه مع إسم كلاس إنتا عامله مايحصلش أى لبس ... لأن الكود بتاعك فى نييم سبييس والكوود بتاعه فى نييم سبييس تانى


Namespaces are the way that .NET avoids name clashes between classes. They are designed to avoid the
situation in which you define a class to represent a customer, name your class Customer, and then
someone else does the same thing


مثال


namespace Programming_C_Sharp
{
namespace Programming_C_Sharp_Test
{
using System;
public class Tester
{
public static int Main( )
{
for (int i=0;i<10;i++)
{
Console.WriteLine("i: {0}",i);
}
return 0;
}
}
}
}
The Tester object now declared within the Programming_C_Sharp_Test namespace is:

Programming_C_Sharp.Programming_C_Sharp_Test.Tester

This name would not conflict with another Tester object in any other namespace, including the
outer namespace Programming_C_Sharp.

0 Comments:

Post a Comment

<< Home