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

can us talk about exchange data between classes?

I find there are some conditions I can't get data defined in another class.
One condition is:
namespace Test
{
class A
{
private int aValue;
public void method1()
{
B b=new B;
int value=b.GetValue(); //Cheers!I can get bValue in class B
}
}

class B
{
private int bValue;
public int GetValue()
{
return bValue;
}
public void method1()
{
//???How can I implement this method to get aValue in class A???
}
}
}

the second condition is in .net remoting:
namespace Test
{
class A
{
private int aValue;
public void method1()
{
TcpServerChannel channel=new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType (typeof(B),"B",WellKnownOb
jectMode.Singleton);
//???then How can I implement this method to get bValue in class
B???
}
}

class B:System.MarshalByRefObject
{
private int bValue;
public void method1()
{
//???How can I implement this method to get aValue in class A???
}
}
}
Nov 15 '05 #1
2 1323
yangxiaoxiang,

If you want b to access members of a, then b needs to have an instance
of a. Now you can create this instance in your method, or you can alter
your method to take a parameter of type a which is then accessed to get the
value.

As for remoting, if you want to get the value of B, then you can just
call GetValue after creating a new instance of B (a proxy should be created
and you should be able to access B remotely).

To get the value of A, the above applies here as well.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"yangxiaoxiang" <li********@163.com> wrote in message
news:eC**************@TK2MSFTNGP11.phx.gbl...
I find there are some conditions I can't get data defined in another class. One condition is:
namespace Test
{
class A
{
private int aValue;
public void method1()
{
B b=new B;
int value=b.GetValue(); //Cheers!I can get bValue in class B
}
}

class B
{
private int bValue;
public int GetValue()
{
return bValue;
}
public void method1()
{
//???How can I implement this method to get aValue in class A???
}
}
}

the second condition is in .net remoting:
namespace Test
{
class A
{
private int aValue;
public void method1()
{
TcpServerChannel channel=new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType (typeof(B),"B",WellKnownOb jectMode.Singleton);
//???then How can I implement this method to get bValue in class
B???
}
}

class B:System.MarshalByRefObject
{
private int bValue;
public void method1()
{
//???How can I implement this method to get aValue in class A???
}
}
}

Nov 15 '05 #2
Thanks,Nicholas Paldino!
But now I find my example may be not so accurate,it should be exactly like
this(a console(or winform) application):

namespace Server
{
class A
{
public int aValue;
[STAThread]
static void Main(string[] args)
{
aValue=10;
TcpServerChannel channel=new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType (typeof(B),"B",WellKnownOb
jectMode.SingleCall);
System.Console.WriteLine("hit to exit");
System.Console.ReadLine();
}
}

public class B:System.MarshalByRefObject
{
public B()
{
}
public int GetAValue()
{
//???How can I get aValue,I don't know how can I get the instance of
class A(a console or a winform application)???
}
}
}

reguards,
yangxiaoxiang
Nov 15 '05 #3

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

Similar topics

1
by: david.kao | last post by:
My boss wants me to find out a way to talk to MS Exchange server directly, so we can develop a .NET application that allows user create or retrieve calendar items in MS Exchange server. I looked at...
19
by: VB Programmer | last post by:
If I have a VB6 and a VB.NET application, or 2 VB.NET applications what is the best way to "talk" between them? They both run on the same PC. Right now I'm just using text files to share...
0
by: scoomey | last post by:
Hi folks- I've got an interesting problem. For our homebrewed PHP intranet application, I will soon be required to give users access to their email/calendar information from Microsoft Exchange....
1
by: Gerhard | last post by:
How can I create a new contact in exchange server from a vb.net web application?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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...

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.