473,807 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with parameter

Hi all,

I have a Webservice in C#, I call this webservice function with a parameter
as String object (named pMessage)
In the function the String object pMessage will be set to corresp. messsage.
But in client program, this parameter is unchanged. Why? How can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)
{
if (..)
pMessage = " 111";
else
pMessage = " 222";
}

Client:

String sMsg = "";
webservice1.xxx (sMsg);
MessageBox.show (sMsg);

Thanks
Martin
Nov 23 '05 #1
9 1535
"Martin" <ma******@freen et.de> wrote in
news:e6******** ******@TK2MSFTN GP15.phx.gbl:
messsage. But in client program, this parameter is unchanged. Why? How
can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)


Of course, this is a by VALUE reference, not a byref.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
Nov 23 '05 #2
Hi,
what do you think about?

I think, when I pass a String Object to a function, the function can change
its value, properties, these changes are made to the original object.

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.
I think, in this case, byref means, the function can change the reference to
another String Object (in C++ is this corresp. to pointer, point to another
object?)

Otherwise, I understood, byval, in, out have meaning only with the primitive
type.



"Chad Z. Hower aka Kudzu" <cp**@hower.org > schrieb im Newsbeitrag
news:Xn******** **********@127. 0.0.1...
"Martin" <ma******@freen et.de> wrote in
news:e6******** ******@TK2MSFTN GP15.phx.gbl:
messsage. But in client program, this parameter is unchanged. Why? How
can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)


Of course, this is a by VALUE reference, not a byref.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Nov 23 '05 #3
"Martin" <ma******@freen et.de> wrote in
news:ub******** ******@TK2MSFTN GP12.phx.gbl:
I think, when I pass a String Object to a function, the function can
change its value, properties, these changes are made to the original
object.
No.

private void Test(string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(y);
button1.Text = y;
}

button1 says Byte, not Hello.

This makes it say Bye:

private void Test(ref string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(ref y);
button1.Text = y;
}

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.
Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I think, in this case, byref means, the function can change the
reference to another String Object (in C++ is this corresp. to pointer,
point to another object?)
Essentially.
Otherwise, I understood, byval, in, out have meaning only with the
primitive type.


No, its can effect objects too. Strings are immutable, so any change you
make makes a NEW string. So if you pass the object byval, there are now two
objects, and the first is not the same as the reference holder to the new
one.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
Nov 23 '05 #4
you need a lvalue to call a function and anyway, change the return type of
the webservice method to string so as to receive a string from the web
service.

with regards,

J.v.
"Martin" wrote:
Hi all,

I have a Webservice in C#, I call this webservice function with a parameter
as String object (named pMessage)
In the function the String object pMessage will be set to corresp. messsage.
But in client program, this parameter is unchanged. Why? How can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)
{
if (..)
pMessage = " 111";
else
pMessage = " 222";
}

Client:

String sMsg = "";
webservice1.xxx (sMsg);
MessageBox.show (sMsg);

Thanks
Martin

Nov 23 '05 #5
Thanks
Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I had tried this way, before I asked newsgroup. But I call this method
false:
bool login(..., out string sMessage)

login(..., sMessage);

Now I wrote:
login(..., out sMessage);

Thanks again

"Chad Z. Hower aka Kudzu" <cp**@hower.org > schrieb im Newsbeitrag
news:Xn******** **********@127. 0.0.1... "Martin" <ma******@freen et.de> wrote in
news:ub******** ******@TK2MSFTN GP12.phx.gbl:
I think, when I pass a String Object to a function, the function can
change its value, properties, these changes are made to the original
object.
No.

private void Test(string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(y);
button1.Text = y;
}

button1 says Byte, not Hello.

This makes it say Bye:

private void Test(ref string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(ref y);
button1.Text = y;
}

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.


Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I think, in this case, byref means, the function can change the
reference to another String Object (in C++ is this corresp. to pointer,
point to another object?)


Essentially.
Otherwise, I understood, byval, in, out have meaning only with the
primitive type.


No, its can effect objects too. Strings are immutable, so any change you
make makes a NEW string. So if you pass the object byval, there are now

two objects, and the first is not the same as the reference holder to the new
one.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Nov 23 '05 #6
Hi,
what do you think about?

I think, when I pass a String Object to a function, the function can change
its value, properties, these changes are made to the original object.

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.
I think, in this case, byref means, the function can change the reference to
another String Object (in C++ is this corresp. to pointer, point to another
object?)

Otherwise, I understood, byval, in, out have meaning only with the primitive
type.



"Chad Z. Hower aka Kudzu" <cp**@hower.org > schrieb im Newsbeitrag
news:Xn******** **********@127. 0.0.1...
"Martin" <ma******@freen et.de> wrote in
news:e6******** ******@TK2MSFTN GP15.phx.gbl:
messsage. But in client program, this parameter is unchanged. Why? How
can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)


Of course, this is a by VALUE reference, not a byref.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Nov 23 '05 #7
"Martin" <ma******@freen et.de> wrote in
news:ub******** ******@TK2MSFTN GP12.phx.gbl:
I think, when I pass a String Object to a function, the function can
change its value, properties, these changes are made to the original
object.
No.

private void Test(string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(y);
button1.Text = y;
}

button1 says Byte, not Hello.

This makes it say Bye:

private void Test(ref string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(ref y);
button1.Text = y;
}

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.
Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I think, in this case, byref means, the function can change the
reference to another String Object (in C++ is this corresp. to pointer,
point to another object?)
Essentially.
Otherwise, I understood, byval, in, out have meaning only with the
primitive type.


No, its can effect objects too. Strings are immutable, so any change you
make makes a NEW string. So if you pass the object byval, there are now two
objects, and the first is not the same as the reference holder to the new
one.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
Nov 23 '05 #8
you need a lvalue to call a function and anyway, change the return type of
the webservice method to string so as to receive a string from the web
service.

with regards,

J.v.
"Martin" wrote:
Hi all,

I have a Webservice in C#, I call this webservice function with a parameter
as String object (named pMessage)
In the function the String object pMessage will be set to corresp. messsage.
But in client program, this parameter is unchanged. Why? How can I do?

The code is following:
[Web ...]
public bool xxx(String pMessage)
{
if (..)
pMessage = " 111";
else
pMessage = " 222";
}

Client:

String sMsg = "";
webservice1.xxx (sMsg);
MessageBox.show (sMsg);

Thanks
Martin

Nov 23 '05 #9
Thanks
Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I had tried this way, before I asked newsgroup. But I call this method
false:
bool login(..., out string sMessage)

login(..., sMessage);

Now I wrote:
login(..., out sMessage);

Thanks again

"Chad Z. Hower aka Kudzu" <cp**@hower.org > schrieb im Newsbeitrag
news:Xn******** **********@127. 0.0.1... "Martin" <ma******@freen et.de> wrote in
news:ub******** ******@TK2MSFTN GP12.phx.gbl:
I think, when I pass a String Object to a function, the function can
change its value, properties, these changes are made to the original
object.
No.

private void Test(string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(y);
button1.Text = y;
}

button1 says Byte, not Hello.

This makes it say Bye:

private void Test(ref string x) {
x = "Hello";
}

private void button1_Click_1 (object sender, System.EventArg s e) {
string y = "Bye";
Test(ref y);
button1.Text = y;
}

I have tried with "public bool xxx( ref String pMessage)", But it is the
same result.


Webservices AFAIK dont support ref parameters. I think they support out
parameters though, you can try:

bool(string InString, out string OutString);
I think, in this case, byref means, the function can change the
reference to another String Object (in C++ is this corresp. to pointer,
point to another object?)


Essentially.
Otherwise, I understood, byval, in, out have meaning only with the
primitive type.


No, its can effect objects too. Strings are immutable, so any change you
make makes a NEW string. So if you pass the object byval, there are now

two objects, and the first is not the same as the reference holder to the new
one.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Nov 23 '05 #10

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

Similar topics

1
1601
by: Mario | last post by:
Hi all From the data-structure below I want to make a table with the following datas RNG@name theName1 RNG/PARAMETER/TEST@name Test1 Test2 RNG/PARAMETER@Para Para1 PASSED/FAILED PASSED/FAILED RNG/PARAMETER@Para Para2 PASSED/FAILED PASSED/FAILED
4
2408
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a hierarchy of algebraic matrices with the addition operation. Thus, I want to have a virtual base class class Matr;
8
10722
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
5
8309
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is not working. The Address column is DataType NVarChar 90, no problem. Any idea?
2
2139
by: guanfenglin | last post by:
Hello, I have a grid view which display and updates the data, however it doesn't work well, I always either get invalid name/number or not all varaibles bound, I am very frustrated at the moment. Thank you very much!! Here is the gridview code:
0
1688
by: le0 | last post by:
Guys, I create a simple insertion in a database using DetailsView control, when i run this page and try to insert some data, the browser returns an error like this --------------------------------------------------------------------------------------------------------------- Server Error in '/Document' Application.
2
2966
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import namespace="System.Web.UI.WebControls" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.OleDb" %>
4
7255
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
10
2378
by: Constantine AI | last post by:
Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it. Here is the function code. Public Function fCalcEquation(strEquation As String) As Long Dim MyDB As DAO.Database Dim rstParameters As DAO.Recordset Dim intParamPosition As Integer Dim strParameter As String Dim strValue As String
8
4639
by: DanicaDear | last post by:
I have something interesting...looking to see if anyone else has came across this. I have a query with parameter and and the query works beautifully every time. However, when I use the wizard to build a report, at the end of the wizard the report opens beautifully, asks for the 2 parameters, and displays results. Beautiful. Then, after closing the report and re-opening, the report promts me for a third, unwanted parameter. ...
0
9720
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
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9193
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
7650
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
6879
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
5546
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
4330
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
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.