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 9 1511
"Martin" <ma******@freenet.de> wrote in
news:e6**************@TK2MSFTNGP15.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/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
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******@freenet.de> wrote in news:e6**************@TK2MSFTNGP15.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/ "Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
"Martin" <ma******@freenet.de> wrote in
news:ub**************@TK2MSFTNGP12.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.EventArgs 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.EventArgs 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/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
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
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******@freenet.de> wrote in news:ub**************@TK2MSFTNGP12.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.EventArgs 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.EventArgs 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/ "Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
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******@freenet.de> wrote in news:e6**************@TK2MSFTNGP15.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/ "Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
"Martin" <ma******@freenet.de> wrote in
news:ub**************@TK2MSFTNGP12.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.EventArgs 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.EventArgs 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/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu
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
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******@freenet.de> wrote in news:ub**************@TK2MSFTNGP12.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.EventArgs 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.EventArgs 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/ "Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 ...
|
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...
|
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...
|
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...
|
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...
|
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
...
|
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...
|
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 -...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |