2 Replies - 331 Views - Last Post: 18 July 2012 - 01:22 PM Rate Topic: -----

#1 Bob10102  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-July 12

Using Methods in Other Classes/Files

Posted 17 July 2012 - 06:11 PM

I'm trying to determine how to use a method that I have in a seperate class/file in my main class. I have searched everywhere but I can't seem to find it. I am a complete noob at C# as I have been using Java and C++.
Is This A Good Question/Topic? 0
  • +

Replies To: Using Methods in Other Classes/Files

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2118
  • View blog
  • Posts: 3,244
  • Joined: 21-June 11

Re: Using Methods in Other Classes/Files

Posted 17 July 2012 - 06:21 PM

This doesn't work any differently in C# than it does in Java.
Was This Post Helpful? 3
  • +
  • -

#3 j0hnzen  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 16-July 12

Re: Using Methods in Other Classes/Files

Posted 18 July 2012 - 01:22 PM

If you have the other class file in the same solution you can just create a new instace of the class and then call the method.

ClassName InstanceName = new ClassName();
InstanceName.OtherClassMethod();



if the other class is not in the same solution you need to add a referanse to it first.
In Visual studio you do this by going to the Solution Explorer and right clicking on referances, select add referance. here you can add referance to another solution/project or to a dll/exe file.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1