TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326.3k
using directives
Dec 5 2011 9:26 AM
This program is given in following website:
http://msdn.microsoft.com/en-us/library/sf0df423(v=vs.80).aspx
Two questions are there
1) Even though nameSpace2 and using directives in nameSpace3 (using NameSpace1 and using NameSpace2;) are comment out program is still executing.
2) We have to use somevar.ToString() to access the ToString() method but here only "somevar" is used to access the ToString() method.
// cs_using_directive2.cs
// Using directive.
using System;
// Using alias for a class.
using AliasToMyClass = NameSpace1.MyClass;
namespace NameSpace1
{
public class MyClass
{
public override string ToString()
{
return "You are in NameSpace1.MyClass";
}
}
}
/*namespace NameSpace2
{
class MyClass
{
}
}*/
namespace NameSpace3
{
//using NameSpace1;
//using NameSpace2;
class MainClass
{
static void Main()
{
AliasToMyClass somevar = new AliasToMyClass();
Console.WriteLine(somevar);
}
}
}
Reply
Answers (
2
)
Object Associations: Aggregation and Containment
Way of defining function in C#