Last question for today.
VB Code:
static void RunApp(object state) { Application.Run((Form)state); }
I am currently converting it to VB.NET, I'd like to know whether "state" is being passed ByRef or ByVal. Does C# have the concept of ByRef/ByVal?
Printable View
Last question for today.
VB Code:
static void RunApp(object state) { Application.Run((Form)state); }
I am currently converting it to VB.NET, I'd like to know whether "state" is being passed ByRef or ByVal. Does C# have the concept of ByRef/ByVal?
I am not quite sure bout that but if I recall correctly,......
if you pass an object it will always be passed by refrence.
But yes you can also specify that using keywords ref (out) or val.
heres an example:
Please do corrcet me if I am wrong!Code:private void button2_Click(object sender, System.EventArgs e)
{
System.Xml.XmlDocument myDoc = new System.Xml.XmlDocument();
testFunction(myDoc);
textBox2.Text = myDoc.SelectSingleNode("//test").InnerText;
}
private void testFunction(System.Xml.XmlDocument myDoc)
{
myDoc.LoadXml("<test>value</test>");
}
Stephan
Reference types (Forms, other complex objects) will always be ByRef. Value types (primatives, structs) will always be ByVal unless the ref modifier is used.
OK, so what I understand is that it's the same deal as in VB.NET, except it's taboo to mention it in C#.
Yup
Burstable Bandwidth
:afrog:
Wont arrays also be essentially byref as well?
That's what I assumed too.