473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Structure and Class

Hello,

I have a class which I am using in my profile.
I made this class Serializable by using:

<Serializable()_
Public Class Options

One of the properties in this class is of type Level where level is a
structure:

Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level

' Access
Private _Access As Level
Public Property Access() As Level
Get
Return _Access
End Get
Set(ByVal value As Level)
_Access = value
End Set
End Property ' Access

Can I make this?

I am not sure if I can use the structure as described since my class
is Serializable because of profile.

Should I turn Level into a Serializable class to with 4 properties?

Thanks,
Miguel

Jun 20 '07 #1
4 1275
Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level
Should I turn Level into a Serializable class to with 4 properties?
Why not make it a simple enum with Flags!

<FlagsPublic Enum Level
Delete = 1
Create = 2
Update = 4
View = 8
End Enum

IMHO, this would be a better choice for you!
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 20 '07 #2
You can use a structure, certainly. However, private members of classes and
structures are not serialized as XML.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"shapper" <md*****@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
Hello,

I have a class which I am using in my profile.
I made this class Serializable by using:

<Serializable()_
Public Class Options

One of the properties in this class is of type Level where level is a
structure:

Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level

' Access
Private _Access As Level
Public Property Access() As Level
Get
Return _Access
End Get
Set(ByVal value As Level)
_Access = value
End Set
End Property ' Access

Can I make this?

I am not sure if I can use the structure as described since my class
is Serializable because of profile.

Should I turn Level into a Serializable class to with 4 properties?

Thanks,
Miguel

Jun 21 '07 #3
On Jun 21, 2:11 pm, "Kevin Spencer" <unclechut...@nothinks.comwrote:
You can use a structure, certainly. However, private members of classes and
structures are not serialized as XML.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@w5g2000hsg.googlegro ups.com...
Hello,
I have a class which I am using in my profile.
I made this class Serializable by using:
<Serializable()_
Public Class Options
One of the properties in this class is of type Level where level is a
structure:
Public Structure Level
Dim Delete As Boolean
Dim Create As Boolean
Dim Update As Boolean
Dim View As Boolean
End Structure ' Level
' Access
Private _Access As Level
Public Property Access() As Level
Get
Return _Access
End Get
Set(ByVal value As Level)
_Access = value
End Set
End Property ' Access
Can I make this?
I am not sure if I can use the structure as described since my class
is Serializable because of profile.
Should I turn Level into a Serializable class to with 4 properties?
Thanks,
Miguel
Hi,

I am serializing my profile classes as binary:
<add allowAnonymous = "false" name = "Collaborator" type =
"Collaborator" serializeAs = "Binary" />

And my class is as follows (I am using the <flagenum sugestion from
Gaurav):

<Serializable()_
Public Class Collaborator

' Permissions
Private _Permissions As Security
Public Property Permissions() As Security
Get
Return _Permissions
End Get
Set(ByVal value As Security)
_Permissions = value
End Set
End Property ' Permissions

' Security
<Serializable()_
Public Class Security

' Level
<Flags()Public Enum Level
Delete = 1
Create = 2
Update = 4
View = 8
End Enum ' Level

' Blogger
Private _Blogger As Level
Public Property Blogger() As Level
Get
Return _Blogger
End Get
Set(ByVal value As Level)
_Blogger = value
End Set
End Property ' Blogger

' Scheduler
Private _Scheduler As Level
Public Property Scheduler() As Level
Get
Return _Scheduler
End Get
Set(ByVal value As Level)
_Scheduler = value
End Set
End Property ' Scheduler
...

End Class ' Security

End Class ' Collaborator

Is this ok?

Thanks,
Miguel

Jun 21 '07 #4
Hi Miguel,
Is this ok?
I do not see any problems.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Jun 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Victor Hannak | last post by:
I have two classes derived from a base class. The two derived classes each utilize a structure that is slightly different from one another. i.e. DerivedClass1: struct NodeStruct { float...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
9
by: Charles Law | last post by:
Suppose I have a structure Private Structure MyStruct Dim el1 As Byte Dim el2 As Int16 Dim el3 As Byte End Structure I want to convert this into a byte array where
3
by: Steve | last post by:
Hello, I created a public Structure in a Standard Module and also an array of Structures. Then I load data into the array of structures in a public sub that I call on the Form load event. ...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
6
by: Laurent | last post by:
Hello, This is probably a dumb question, but I just would like to understand how the C# compiler computes the size of the managed structure or classes. I'm working on this class: public...
11
by: aaragon | last post by:
Hi everyone. I'm trying to write a class with policy based design (Alexandrescu's Modern C++ Design). I'm not a programmer but an engineer so this is kind of hard for me. Through the use of...
2
by: David | last post by:
Hi all, using 1.1 I am creating a dynamic menu structure for my site, however, I may refer to the structure many times within a page. This would be fine if I was doing it all in the...
0
by: MikeCS | last post by:
Hi all I would like some help with this issue. I am new to VB 2005 (OK with VB6) My problem is that I cannot seem to return a structure from a function. Example: I defined a structure in a...
4
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.