Ask a Question related to ASP.NET General, Design and Development.
-
yysiow #1
function object
hi All
in vb function can pass object, like
Function test(ByVal txt As TextBox)
txt.Text = "text"
End Function
if i want to do this function using C#.
how can i do?
thanks.
yysiow Guest
-
onChanged function not working with Shared Object
Hey guys, I'm trying to get my Shared Object script to flush() data when I use the onChanged function instead of a Save button b/c I'm creating a... -
[FMX]Problem with caling function in linked object
I'm trying to achief the following: In my flash movie I load some MC during runtime. Everything is fine, the MC show themselves on the... -
New Function gives Object Expected Error
Hello, This problem has been driving me nuts... I have a set of functions and code which work fine by itself and another function which works... -
object in a function!?
I have one little issue here.... let say that I have a function , and in that function some object functions are used.... which is better ... -
Can you return a dictionary object from a function?
"Mark Schupp" <mschupp@ielearning.com> wrote in message news:OwPxqtxPDHA.1748@TK2MSFTNGP11.phx.gbl... doh! -
Kevin Spencer #2
Re: function object
In .Net, EVERYTHING is an object. So, of course, you can pass one as a
parameter. However, if you want to make a change to the object passed, you
should pass it by Reference. In .Net, you would do it like so:
Function test(ByRef txt As TextBox)
txt.Text = "text"
End Function
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
[url]http://www.takempis.com[/url]
Big things are made up of
lots of little things.
"yysiow" <yysiow@ytlesolutions.com> wrote in message
news:%23DMHGcnSDHA.1552@TK2MSFTNGP10.phx.gbl...> hi All
>
> in vb function can pass object, like
>
> Function test(ByVal txt As TextBox)
>
> txt.Text = "text"
>
> End Function
>
> if i want to do this function using C#.
> how can i do?
> thanks.
>
>
Kevin Spencer Guest
-
PJ #3
Re: function object
That's unnecesssary and incorrect. The byval and byref refer to the pointer
of the object, not the object itself. Attributes of the TextBox instance
would still be modified outside of the function they were modified in.
However, for value ( base ) types such as int32 you would need to pass it
byref if you want to modify the instance. There is rarely a need for that
as proper scoping eleminates this need.
"Kevin Spencer" <kevin@takempis.com> wrote in message
news:%23yDT8FtSDHA.3796@tk2msftngp13.phx.gbl...> In .Net, EVERYTHING is an object. So, of course, you can pass one as a
> parameter. However, if you want to make a change to the object passed, you
> should pass it by Reference. In .Net, you would do it like so:
>
> Function test(ByRef txt As TextBox)
>
> txt.Text = "text"
>
> End Function
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> [url]http://www.takempis.com[/url]
> Big things are made up of
> lots of little things.
>
> "yysiow" <yysiow@ytlesolutions.com> wrote in message
> news:%23DMHGcnSDHA.1552@TK2MSFTNGP10.phx.gbl...>> > hi All
> >
> > in vb function can pass object, like
> >
> > Function test(ByVal txt As TextBox)
> >
> > txt.Text = "text"
> >
> > End Function
> >
> > if i want to do this function using C#.
> > how can i do?
> > thanks.
> >
> >
>
PJ Guest
-
Kevin Spencer #4
Re: function object
True, but that sort of information goes over the heads of certain types of
developers, for example, VB developers that are migrating to VB.Net. As you
stated, the need is rare, but not non-existent. For example, when you pass
an object without passing it ByRef, you can not change the assignment of the
object variable, only its' properties. Understanding the difference between
reference types and value types is also a more advanced topic. So I
simplified it. Passing an object ByRef hurts nothing.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
[url]http://www.takempis.com[/url]
Complex things are made up of
lots of simple things.
"PJ" <pjwal@hotmail.com> wrote in message
news:eWPHVF7XDHA.1004@TK2MSFTNGP12.phx.gbl...pointer> That's unnecesssary and incorrect. The byval and byref refer to theyou> of the object, not the object itself. Attributes of the TextBox instance
> would still be modified outside of the function they were modified in.
>
> However, for value ( base ) types such as int32 you would need to pass it
> byref if you want to modify the instance. There is rarely a need for that
> as proper scoping eleminates this need.
>
>
> "Kevin Spencer" <kevin@takempis.com> wrote in message
> news:%23yDT8FtSDHA.3796@tk2msftngp13.phx.gbl...> > In .Net, EVERYTHING is an object. So, of course, you can pass one as a
> > parameter. However, if you want to make a change to the object passed,>> > should pass it by Reference. In .Net, you would do it like so:
> >
> > Function test(ByRef txt As TextBox)
> >
> > txt.Text = "text"
> >
> > End Function
> >
> > --
> > HTH,
> >
> > Kevin Spencer
> > Microsoft MVP
> > .Net Developer
> > [url]http://www.takempis.com[/url]
> > Big things are made up of
> > lots of little things.
> >
> > "yysiow" <yysiow@ytlesolutions.com> wrote in message
> > news:%23DMHGcnSDHA.1552@TK2MSFTNGP10.phx.gbl...> >> > > hi All
> > >
> > > in vb function can pass object, like
> > >
> > > Function test(ByVal txt As TextBox)
> > >
> > > txt.Text = "text"
> > >
> > > End Function
> > >
> > > if i want to do this function using C#.
> > > how can i do?
> > > thanks.
> > >
> > >
> >
>
Kevin Spencer Guest



Reply With Quote

