get members in partial class

I am currently trying to use partial classes to extend my business logic for a project using the Entity Framework & vb.NET.  My question is this.  In my partial class is it possible to get the values for members (properties) from the main class.

So for instance if my main class was

Public Class MyClass

	Public Property String1 as string

End Class

Open in new window


I would want to be able to do something like this.  Is it possible?
Partial Class MyClass

	Public Function MyMethod() as string

		Return String1

	End Function

End Class

Open in new window

MRSAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ladarlingConnect With a Mentor Commented:
Yes, you should have access to all of the members of your full class.
This example works fine for me:
 

Public Class Fish
    Dim name As String = "Nemo"
End Class
Partial Public Class Fish
    Public Function GetName() As String
        Return name
    End Function
End Class

Open in new window

0
 
Gururaj BadamCommented:
The main class should also be marked as Partial otherwise I'm afraid whether it will work.
0
 
ladarlingCommented:
The Partial identifier is not required on the main class definition.... that is by design so that premade classes can be expanded with a Partial ....
0
 
Gururaj BadamCommented:
In C# I see it as error - quite strange.
0
 
MRSAuthor Commented:
Well that was a lot simpler the I expected.. :-)

Thank you for the quick turn around...
0
All Courses

From novice to tech pro — start learning today.