PC Review


Reply
Thread Tools Rate Thread

cannot set property value in a structure using Me

 
 
Sankar Nemani
Guest
Posts: n/a
 
      17th Sep 2004
Does any one know why the following code works the way? and in C# it works in a different way what is the meaning of "Me" in VB.NET and why is it different than in C#

Structure Test
Private mName As String

Property Name() As String
Get
Return Me.mName
End Get
Set(ByVal Value As String)
Me.mName = Value
End Set
End Property

Sub foo(ByVal s As String)
Me.Name = s 'this line fails
Name = s 'this line does not fail
End Sub

End Structure

C# code
struct Test
{
string mName;

public string Name
{
get
{
return this.mName;
}
set
{
this.mName = value;
}
}

public void foo(string s)
{
this.Name = s; //no error
}
}

 
Reply With Quote
 
 
 
 
Think_Fast
Guest
Posts: n/a
 
      17th Sep 2004
I don't know why it doesn't work using Me that way. But I found that this seems to work.

Public Sub foo(ByVal s As String)
Dim r As String
r = (Me.Name = s).ToString
Name = s 'this line does not fail
End Sub

"Sankar Nemani" <(E-Mail Removed)> wrote in message news:%23Ow%(E-Mail Removed)...
Does any one know why the following code works the way? and in C# it works in a different way what is the meaning of "Me" in VB.NET and why is it different than in C#

Structure Test
Private mName As String

Property Name() As String
Get
Return Me.mName
End Get
Set(ByVal Value As String)
Me.mName = Value
End Set
End Property

Sub foo(ByVal s As String)
Me.Name = s 'this line fails
Name = s 'this line does not fail
End Sub

End Structure

C# code
struct Test
{
string mName;

public string Name
{
get
{
return this.mName;
}
set
{
this.mName = value;
}
}

public void foo(string s)
{
this.Name = s; //no error
}
}

 
Reply With Quote
 
Peter Huang
Guest
Posts: n/a
 
      17th Sep 2004
Hi Sankar,

This is a known issue and the product group is planning to fix the problem
in the next version of .net framework but I can not guarantee if that will
be done.
Here is a KB, you may take a look.
BUG: You Cannot Use the Me Keyword Before the Property Name in a Microsoft
Visual Basic .NET Structure (819354)
http://support.microsoft.com/default...B;EN-US;819354

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Sankar Nemani
Guest
Posts: n/a
 
      21st Sep 2004
That helps.
Thanks
Sankar
""Peter Huang"" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Sankar,
>
> This is a known issue and the product group is planning to fix the problem
> in the next version of .net framework but I can not guarantee if that will
> be done.
> Here is a KB, you may take a look.
> BUG: You Cannot Use the Me Keyword Before the Property Name in a Microsoft
> Visual Basic .NET Structure (819354)
> http://support.microsoft.com/default...B;EN-US;819354
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



 
Reply With Quote
 
Peter Huang
Guest
Posts: n/a
 
      22nd Sep 2004
Hi Sankar,

You are welcome, I am glad my reply is of help.
Cheers!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
structure as a property Stivo Microsoft Dot NET Framework Forms 4 30th Dec 2007 10:33 PM
Structure as object property JSheble Microsoft C# .NET 6 14th Dec 2005 07:03 PM
Using a structure as a property in a class gives error when accessing properties of structure D Witherspoon Microsoft VB .NET 6 5th Mar 2005 06:43 AM
Using a structure as a property in a class gives error when accessing properties of structure D Witherspoon Microsoft Dot NET 6 5th Mar 2005 06:43 AM
Using a structure as a property in a class gives error when accessing properties of structure D Witherspoon Microsoft Dot NET Framework Forms 6 5th Mar 2005 06:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 AM.