0

I was wondering... If I want to store a MASSIVE string in my program and also store sub strings of the main string (i.e. store every word and store every sentence as arrays of strings) how can I do so without making 2 copies of the first massive string?

In C++ I would just use pointers to parts of the string... Is there an equivalent method in C#?

5
  • 1
    Pointers in C++ are just memory addresses. Likewise you can store indices of the massive string which are integers (and take up the same memory than C++ pointers). Commented Jun 12, 2013 at 6:54
  • Why not store the indices of the start and end of the substring? Commented Jun 12, 2013 at 6:54
  • MASSIVE == maybe a full book.. See Tigran's answer, I just had a block and made this question as I was on my way to work so I would loose my train of thought. Brain just skipped a beat, I left my seat and hit myself in the head... Hopefully this might be able to help somebody else Commented Jun 12, 2013 at 6:59
  • If you could store the index of sub-strings in an array in the way you want? Commented Jun 12, 2013 at 7:00
  • Yeah that's what I plan to do Commented Jun 12, 2013 at 7:12

1 Answer 1

2

You can store indices of the start and end of that substring your going to refer to.

In this case, if your string is going to change over runtime of your program, your "substring" will refer to the most updated version of the string, but I'm not sure, cause it's not clear from the question, if this is actually an expected behavior.

Sign up to request clarification or add additional context in comments.

2 Comments

I feel rather stupid.. I've staired at the problem for a while.. And couldn't think of a solution... Then as soon as I wrote the question and left my room, I was like... Get String.. Convert to String[] for every word Make {int start, int end} array for every sentence. :| lol you don't think until you leave the computer... I would have thought a lil longer, but it was killing me and I was on my way to work so I was about to loose my train of thought.
@MichaelCrook: it happens, sometimes :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.