473,395 Members | 1,443 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,395 software developers and data experts.

Refering the method of one class file to an another class file in c#

hi,

Am doing coding in c#,... actually i am creating four different classes in four different . And all classes has the same namespace. What to be done
If i want invoke the method of one class file from an another class file..

i just created a object of another class in the present class but am unable to invoke the method.........

could u plz help me...............
Mar 17 '08 #1
3 1279
nateraaaa
663 Expert 512MB
hi,

Am doing coding in c#,... actually i am creating four different classes in four different . And all classes has the same namespace. What to be done
If i want invoke the method of one class file from an another class file..

i just created a object of another class in the present class but am unable to invoke the method.........

could u plz help me...............
Have you set the access type to public for the method you are trying to call?

Class1 calls method in Class2

Expand|Select|Wrap|Line Numbers
  1.  obj object1 = Class2.Method1();
Class2

Expand|Select|Wrap|Line Numbers
  1.  public object Method1() 
  2. {
  3. return new object;
  4. }
  5.  
Give this a try

Nathan
Mar 17 '08 #2
Frinavale
9,735 Expert Mod 8TB
Have you set the access type to public for the method you are trying to call?

Class1 calls method in Class2

Expand|Select|Wrap|Line Numbers
  1.  obj object1 = Class2.Method1();
Class2

Expand|Select|Wrap|Line Numbers
  1.  public object Method1() 
  2. {
  3. return new object;
  4. }
  5.  
Give this a try

Nathan
All you have to do is create an instance of the object that you need to use and call it's public methods.
-Frinny
Mar 17 '08 #3
r035198x
13,262 8TB
Have you set the access type to public for the method you are trying to call?

Class1 calls method in Class2

Expand|Select|Wrap|Line Numbers
  1.  obj object1 = Class2.Method1();
Class2

Expand|Select|Wrap|Line Numbers
  1.  public object Method1() 
  2. {
  3. return new object;
  4. }
  5.  
Give this a try

Nathan
Not quite. To access a method using class name alone requires that the method be static. To access instance methods, you need an instance of that class. The public modifier controls access across namespaces.
Mar 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: gregory.petrosyan | last post by:
Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ????) print x All I want is to make self.data the default argument for self.f(). (I
3
by: Ross Holder | last post by:
I've created a number of business entities for an applciation I'm working on in ASP.NET (Framework 1.1) and would like to quickly get data into a BoundColumn for a control that consums a...
4
by: JJ | last post by:
My master page contains various graphics that are referenced from the images folder. As long as the container pages are at the same level (ie. the top level looking at the solution explorer in...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
21
by: glenn | last post by:
hi - Im quite new to python, wondering if anyone can help me understand something about inheritance here. In this trivial example, how could I modify the voice method of 'dog' to call the base...
1
by: Sarwan | last post by:
Hello everybody I have a solution in which there is an unmanaged MFC application. Then i added a new managed .Net Windows Form application. I was trying to refer an header file of unmanaged...
10
by: safaci2000 | last post by:
Hi all, I have a DLL that I need to access. I've managed to load it and unload it successfully. The compiler is happy no complaints or warning. I need to refer to a class object that was...
3
by: Mark Poppers | last post by:
Assume the following sequence of user actions starting with a Form and an e.g. StatusStrip: 1.) User doubleclicks on the StatusStrip 2.) VisualStudio jumps to the new generated source code ...
4
by: lilyumestar | last post by:
I have project I have to do for class. We have to write 4 different .java files. Project2.java HouseGUI.java House.java HouseSorting.java I already finish House.java and I need to work on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.