0

I wanted to split a string of length 200 characters and place them in the request DTO data member noteline1---noteline18. I want to make sure that only 78 characters are allowed and the remaining characters should be moved to another data member(if noteline1 is filled with 78 characters, then it should fill the remaining characters to another empty noteline). I have used the following code

if (requestNoteReason.Length < 78)
 {
     if (reqPropertyInfo.Name.ToLower() == null)
      {
            reqPropertyInfo.SetValue(request, requestNoteReason, null);
           break;
      }
 }

      else
      {
          reqPropertyInfo.SetValue(request, requestNoteReason.Substring(0, 78), null);
          requestNoteReason = requestNoteReason.Substring(78, requestNoteReason.Length - 78);
          i++;

         continue;
     }

The above code work fine but I want that it should not place the remaining string character on the non-empty noteline data member. It should first find the remaining empty Noteline(noteline1---noteline18) and then assign the remaining characters on them. How will I achieve it?

Running Rabbit
  • 2,634
  • 15
  • 48
  • 69
  • I can't parse "I want that it should not place the remaining string character on the variable which already have value in it" - could you clarify? It's not clear which variables you have available... is there any reason you're not just using a `List`? – Jon Skeet Jul 26 '12 at 07:31
  • I have edited the code now. I think it will clear up things – Running Rabbit Jul 26 '12 at 07:40
  • @HimanshuNegi Do you use this code `if (reqPropertyInfo.Name.ToLower() == null) ` to check if a property has a value? And is this property represents a noteline(s) you're talking about? – Malik Amurlayev Jul 26 '12 at 07:44
  • It's not clearer... maybe expanding the code so we can see the loop that this is in? – NPSF3000 Jul 26 '12 at 07:50

0 Answers0