Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2005, 11:40 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 5
Thanked 0 Times in 0 Posts
Default calling private method from another class

Could anybody plz tell me How to call a private method from different or another class in C# any examples would be appreciated, thank you
 
Old December 8th, 2005, 01:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Exploring the concept of Friend classes will help you.

Regards
Ankur Verma
 
Old December 11th, 2005, 12:31 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Private methods are private and thus not public. That's the idea of a private method.

But like Ankur suggests, a method with the 'Friend' ('internal' in C#) modifier might work for you. This allows other classes within the same assembly to see the method. However, the method is not publicly accessible from *outside* the assembly.

-Peter
 
Old December 16th, 2005, 07:56 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Could anybody plz tell me How to call a private method from different or another class in C#
well,you can't call any private method from another class unless for nested classes.

_____________
Mehdi.
software student.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Java Method via javascript basildudin J2EE 5 October 16th, 2008 12:00 AM
Calling a btn_click method without clicking it dhirajDac VB.NET 1 April 18th, 2008 08:24 AM
Calling a btn_click method dhirajDac ASP.NET 2.0 Professional 2 April 18th, 2008 07:52 AM
Calling a function on every method call Takashi321 General .NET 1 September 21st, 2007 09:33 AM
Calling a method from Linkbutton in DataList swifty_programmer ASP.NET 2.0 Basics 1 July 28th, 2007 05:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.