473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Friend classes

Is there such a thing in C#? If not, is there a workaround or suggested
shift of paradigm?

I know friendly classes can be evils sometimes, but some other times it may
be very helpful. If you think about the memento pattern, it is nice for the
memento to expose two interfaces, one for the world and another one for the
originator...

Any comments?

Cheers

Padu
May 11 '06 #1
3 3879
> Is there such a thing in C#? If not, is there a workaround or
suggested shift of paradigm?


Sure. Use an internal class.

Best Regards,
Dustin Campbell
Developer Express Inc
May 11 '06 #2
Sort of .. the internal keyword makes things visible only to other classes
within your assembly or friend assemblies .. this is a bit larger in scope
than delcaring another class a friend but can offer similar functionality.

Cheers,

Greg Young
MVP - C#
"Padu" <pa**@merlotti.com> wrote in message
news:ZM******************************@iswest.net.. .
Is there such a thing in C#? If not, is there a workaround or suggested
shift of paradigm?

I know friendly classes can be evils sometimes, but some other times it
may be very helpful. If you think about the memento pattern, it is nice
for the memento to expose two interfaces, one for the world and another
one for the originator...

Any comments?

Cheers

Padu

May 11 '06 #3
Just as in real life, good planning will obviate the need for friends. :-)

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Padu" <pa**@merlotti.com> wrote in message
news:ZM******************************@iswest.net.. .
Is there such a thing in C#? If not, is there a workaround or suggested
shift of paradigm?

I know friendly classes can be evils sometimes, but some other times it
may be very helpful. If you think about the memento pattern, it is nice
for the memento to expose two interfaces, one for the world and another
one for the originator...

Any comments?

Cheers

Padu

May 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sebastian Faust | last post by:
Hi, is a construction like the following possible: template<class view_model> class template_clase { protected: template_clase() {} virtual ~template_clase() {}
15
by: Samee Zahur | last post by:
Question: How do friend functions and static member functions differ in terms of functionality? I mean, neither necessarily needs an object of the class to be created before they are called and...
7
by: Jesper | last post by:
I need to grant a class access to protected fields of another class in the way its possible in C++ with the friend keyword. However I would like to keep the class protected towards other class...
4
by: darrel | last post by:
In the context of VB.net, when/why would one use a 'friend class'. I'm finding lots of references to friend classes on google, but not a simle definition of what they actually are. Actually, if...
2
by: anongroupaccount | last post by:
I have a smaller class that essentially acts as a record for a larger class (stored in a vector inside of the larger class). In a sense, it's splitting functionality over two classes. I don't...
8
by: toton | last post by:
Hi, I have a parser interface , which is class IParser{ public: void readHeader(Document& doc)= 0; void readCC(CC& cc) = 0; }; Now, there are 3 kinds of parser which extends (implements)...
3
by: Neal | last post by:
Hi all Why do I get a compiler error with the following code. Friend Class SomeClass End Class Public Class SomePublicClass Protected Friend Function AMethod As SomeClass
5
by: Amit Gupta | last post by:
How do I do it (either by friend or by any other hack). I have three class, I am just writing derivation below: class A{} class B{} class C : public class B{} class D: public class B ()
19
by: subramanian100in | last post by:
Stroustrup, in his book TC++PL 3rd Edition, in page 16, under the section '1.8 Advice' has mentioned the following: Don't use global data(use members) Don't use global functions Don't use...
1
by: Immortal_Nephi | last post by:
I want to show you an example how two classes can have relationship instead of an inheritance. The inheritance is not an option if you want to define two classes. The relationship between two...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.