Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:39:23+00:00 2026-06-17T11:39:23+00:00

Possible Duplicate: C#: Structs versus classes I am creating a library, which is relatively

  • 0

Possible Duplicate:
C#: Structs versus classes

I am creating a library, which is relatively small to require a database, containing tags of MP3 files.

I know that it would be better to stick with structures if I have fixed size data like integers, doubles etc… However in my case, I have strings and lists that contains strings and even other structures… If I will go with structures, it will look like this:

Public Structure STitle
    Dim Title As String
    Dim Path As String
End Structure

Public Structure SAlbum
    Dim Album As String
    Dim Songs As List(Of STitle)
End Structure

Public Structure SArtist
    Dim Artist As String
    Dim Albums As List(Of SAlbum)
End Structure

Then, I will have something like this:

Public SongLibrary As New List(Of SArtist)

The strings and lists are confusing me, especially speed-wise. Since I will be searching through lots of song, I want to make sure that I am using the fastest one.

I am also confused about boxing and unboxing. I assume that the list of string contains only the pointers to “the string” and same for the structures(trying to think low level). However, I don’t know whether boxing-unboxing, which slows down the searching(a reason to not to use arraylists), takes place or not since the sizes are impossible to determine(or is it?)

So which one to pick? Class, or structure? or is there something else suiting better?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:39:23+00:00Added an answer on June 17, 2026 at 11:39 am

    I know that it would be better to stick with structures if I have fixed size data like integers, doubles etc

    How do you “know” that? In my experience, it’s very rarely a good idea to create a custom value type. It does happen – there are plenty in my Noda Time project, for example – but usually I would be wary. I’d also be very wary before exposing mutable structures.

    I am also confused about boxing and unboxing. I assume that the list of string contains only the pointers to “the string” and same for the structures(trying to think low level).

    For structures, there isn’t a pointer (reference). A List(Of Integer) is implemented with an Integer() for example. The array contains the values directly. With generic collections, no boxing is required.

    See the class design guidelines for more information, but basically I’d default to using classes unless I had a really compelling reason to create a structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why are structs stored on the stack while classes get stored on
Possible Duplicate: Is it safe for structs to implement interfaces? Take this code: interface
Possible Duplicate: When to use forward declaration? C++ classes with members referencing each other
Possible Duplicate: Why doesn't GCC optimize structs? Why doesn't C++ make the structure tighter?
Possible Duplicate: Octave/MATLAB: How to compare structs for equality? is there a simple comparison
Possible Duplicate: Send and receive NSData via GameKit I have struct which consists of
Possible Duplicate: CGFloat addition bug? I have a CGPoint (which is just a struct
Possible Duplicate: c++ sort with structs I am trying to figure out how to
Possible Duplicate: Request for member which is of non-class So I've created an ADT
Possible Duplicate: How do you compare structs for equality in C? In a macro

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.