GDay all,Something seems odd to me....I wrote a simple C# functionpublic void bind(ref object a, ref object b, bool atob){if(atob)b = a;elsea = b;}I call it from a windows app.string data = "moo";bind(ref (object)this.Text, ref (object)data, false);As I expected I got Error CS1510 "A ref or out argument must be anlvalue".Here is what I didnt''t expect, when I wrote a vb.net equivilant:Public Sub bind(ByRef a As Object, ByRef b As Object, ByVal atob AsBoolean)If (atob) Thenb = aElsea = bEnd IfEnd Suband call it from a windows app:Dim data As String = "moo"bind(Me.Text, data, False)Not only did it compile it also executed and worked - the forms titlewas changed to "moo".Why does VB.NET not spit the dummy?Is it possible to coax C# into doing whatever vb did?-DM 解决方案I''ve had a look at what VB.NET does under the covers, and basically itcreates temporary objects, passes those by reference, and then setsdata and Me.Text to the results afterwards. Utterly horrible, if youask me... but it only does it that way if the parameters are eitherproperties or subtypes of the formal parameter types.--Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeetIf replying to the group, please do not mail me too 这篇关于“ref object a” <> “ByRef a As Object” ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-27 17:55