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 7508239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:38:46+00:00 2026-05-29T22:38:46+00:00

I know that strings have variable length, therefore they need variable space in memory

  • 0

I know that strings have variable length, therefore they need variable space in memory to be stored. When we define a string item in a struct, the struct‘s size would then be variable in length.

Older languages managed this by using fixed-length strings. However, there is no way to define fixed-length strings in C#, and C# manages normal strings in structs pretty good.

This becomes more weird when we define an array of such structs, or simply an array of strings. As result of any change (decrease/increase) in length of one string, all forward structs must be shifted.

How does C# handle variable-length strings in structs?

  • 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-05-29T22:38:47+00:00Added an answer on May 29, 2026 at 10:38 pm

    The string itself is not stored in the struct. Instead a reference to the string is stored in the struct, so the struct size never changes.

    string is not a value type; .NET strings are interned, which means that each unique string is stored in a look-up table in memory.

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

Sidebar

Related Questions

Possible Duplicate: Split String into smaller Strings by length variable I have seen solutions
I have a variable string like such: [Text that changes]:SPACE: where the :SPACE: is
We know that string is a reference type , so we have string s=God
I have a string input that i do not know whether or not is
I have a binary file with variable length record that looks about like this:
I know that buffer overruns are one potential hazard to using C-style strings (char
do you know any good algorithms that match two strings and then return a
I know that using Dim currUser As String = Request.ServerVariables(LOGON_USER) returns the Domain\Username, but
I know that I can pass a string as the second parameter to the
I know that for an integer, you can use: int value; I tried: string

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.