-1

I have string label = 20. I have added label prefix as "Goal" .in between i added \n . Two lines are not coming instead one line only appearing.I need Expected Output.

Expected Output:

Goal                  
20

ActualOutput:

Goal20

I have tried below methods, its not working

  string label = Goal;
  string cReturns = System.Environment.NewLine + "\n" + "\r";
  string[] words = label.Split(cReturns.ToCharArray());
  label = words +20;

or

label = "Goal\n20";

CAN ANYONE SUGGEST ME CORRECT ANSWER

Thanks

York Shen
  • 9,014
  • 1
  • 16
  • 40
bhuvana
  • 43
  • 5

3 Answers3

0

You try 
 instead of \n: label = "Goal
20";

Luke Le
  • 728
  • 1
  • 9
  • 24
0

If i add drawtext in customview its not working

You could strip the \n and then offset the Y to get your text on the next line.

For Example :

string lab = "Goal";
canvas.DrawText(lab, 100, 100, p);
canvas.DrawText("20", 100, 150, p);

Effect.

York Shen
  • 9,014
  • 1
  • 16
  • 40
  • \n wont work for drawtext? is there any other solution? – bhuvana Nov 06 '17 at 12:52
  • @bhuvana, this is the simplest solution, for more information, you could refer to : https://stackoverflow.com/questions/6756975/draw-multi-line-text-to-canvas – York Shen Nov 06 '17 at 12:57
0

using System.Environment.NewLine will help.

for example:

await MainPage.DisplayAlert("Connection Problem!", "Can't 
access backEnd at the moment Please try again later!" 
                + System.Environment.NewLine + ex.Message,
                "OK");
Dharman
  • 30,962
  • 25
  • 85
  • 135
Michael O
  • 67
  • 5