473,836 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i use the concept of friend in c#?

p
I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!

Mar 8 '07 #1
9 1676
Hello P,

Use [System.Runtime. CompilerService s.InternalsVisi bleToAttribute] which allows
you to specify assemblies which have access to non-public types within the
assembly to which you apply the attribute

---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

PI know the word friend is not supported in c# and its not a very good
Pthing to but i would be thankful if anybody can explain in simple
Pwords how can i implement it!
P>
Mar 8 '07 #2
"internal" is the C# equivalent.

--
HTH,

Kevin Spencer
Microsoft MVP

Help test our new betas,
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"p" <na******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!

Mar 8 '07 #3
p wrote:
I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!
Check out 'internal'.

-- Barry

--
http://barrkel.blogspot.com/
Mar 8 '07 #4
"p" <na******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!
http://www.thescripts.com/forum/thread235353.html

This is a superb reference site for such matters:
http://www.dnzone.com/ShowDetail.asp?NewsId=356
Mar 8 '07 #5
Kevin Spencer wrote:
"internal" is the C# equivalent.
Doesn't that depend on which "friend" you are talking about? I know the OP
wasn't clear. Internal is equivalent to VB Friend, but it is not equivalent
to C++ friend.

The friend access modifier in C++ allows you to be very specific as to who
your friends are. Internal in C# means simply that anyone in the assembly
can access this. Internal is similar, but not equivalent, to C++ friend.
--
Tom Porterfield

Mar 8 '07 #6
Hi,

"p" <na******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!
internal carries a similar meaning, is not the same though.

What is exactly what you need to do? Maybe we can suggest you the way to go.
--
Ignacio Machin
machin AT laceupsolutions com
Mar 8 '07 #7
If you mean the VB notion of 'Friend', then see the other posts ("internal") .
If you mean the C++ notion of 'friend', then no equivalent exists in C#.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Michael Nemtsev" wrote:
Hello P,

Use [System.Runtime. CompilerService s.InternalsVisi bleToAttribute] which allows
you to specify assemblies which have access to non-public types within the
assembly to which you apply the attribute

---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

PI know the word friend is not supported in c# and its not a very good
Pthing to but i would be thankful if anybody can explain in simple
Pwords how can i implement it!
P>
Mar 8 '07 #8
"p" <na******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I know the word friend is not supported in c# and its not a very good
thing to but i would be thankful if anybody can explain in simple
words how can i implement it!
The way we implement the "friend" concept is by making the method public,
and testing that the caller is one of a set of particular methods or
classes.

I think I don't like it, but it does do the job.

///ark
Mar 8 '07 #9
You're right, of course. I did not think of the C++ friend access modifier,
as I assumed (point of failure) that if the poster was asking the question,
he was a VB developer.

--
HTH,

Kevin Spencer
Microsoft MVP

Help test our new betas,
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Tom Porterfield" <tp******@mvps. orgwrote in message
news:ed******** ******@TK2MSFTN GP05.phx.gbl...
Kevin Spencer wrote:
>"internal" is the C# equivalent.

Doesn't that depend on which "friend" you are talking about? I know the
OP wasn't clear. Internal is equivalent to VB Friend, but it is not
equivalent to C++ friend.

The friend access modifier in C++ allows you to be very specific as to who
your friends are. Internal in C# means simply that anyone in the assembly
can access this. Internal is similar, but not equivalent, to C++ friend.
--
Tom Porterfield

Mar 9 '07 #10

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

Similar topics

3
2408
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
15
6600
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 either has access only to static members of the class (ie. assuming no object of the class is in scope - neither by arguments recieved nor by local declarations). Any static member function like this: //accessing static member i static void...
5
1479
by: Alfonso Morra | last post by:
Hi, I've written a very simple Simpleton design pattern class template. This was supposed to illustrate a point. Although it compiles without nay errors, I get link errors (unresolved external), during linking - before anyone jumps to conclusions that this is OT, please check the linker error message below, it is NOT OT. Here are my class declarations/definitions:
8
1184
by: Bruce D | last post by:
I'm developing my first VB.NET application and I want to use good coding technique, but I'm a little confused about 'modules and 'classes'. I have several windows forms that have to connect to my data (MySQL). During my testing, I created a ODBCconnection object via code (I didn't want to use the windows form object because I'm going to want to use this from other forms)...and all was great. So, now I need to put that code in a place...
4
2365
by: Madhav | last post by:
Hi all, I am a newbie in c++. I want to know what is the philosophical reason behind the existence of friend functions. I thought giving access to private data to a function which is not a member of the class is a violation of encapsulation. Thanks, Madhav.
9
3738
by: Adam Badura | last post by:
I have code like this template<int size> big_int { /* ... */ template<int size2> friend class big_int<size2>; }; What I wanted to achive is to be able to easly convert different sized big_int's and to operate on them. But for this I need to be able to access private data of big_int. The problem is that for differenc sizes this are of
2
1525
dmjpro
by: dmjpro | last post by:
actually i working with JSP. but yesterday a friend was working with servlet. there a Q. arised. that is ...... if my servlet class extends HttpServlet class then if i leave all doGet and doPost method implementation then the service can't be resolved if the request comes with POST or GET method? i m telling this because these methods r protected. plz clear my conception. kind regards.
5
1924
by: tuananh87vn | last post by:
hi, I'mm writing script for adding friend to a friend list.i'm using a form including friend_name (text), message (textarea) and below is my code: if(isset($_POST)) { include('dbconnect.php'); $friend=$_POST; $user=$_COOKIE;
6
3170
by: WaterWalk | last post by:
I find friend declaration just very tricky. I tried the following examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are surprising. Example1: namespace ns1 { class Test { friend void func()
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10527
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10571
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9358
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7773
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6973
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4441
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3102
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.