카테고리 없음

[씨#] 이 메시지 상자를 통해 C #을 사용하여 각 문장을 고유 한 줄에 올바르게 입력하려면 어떻게해야합니까?

필살기쓰세요 2021. 2. 19. 13:11

Try using \n characters for each newline.

private void button5_Click(object sender, EventArgs e)
{
    MessageBox.Show(
        "In order to bet 'High' press the 'ALT' Key and the 'H' key at the same time.\n" + 
            "In order to bet 'Low' press the 'ALT' Key and the 'L' key at the same time.\n" + 
                "In order to reduce the bet's value in half  press the 'ALT' Key and the 'H' key at the same time.");
                }
                
-------------------

try this

 {MessageBox.Show("In order to bet 'High' press the 'ALT' Key and the 'H' key at the same time." + Environment.NewLine 
  + "In order to bet 'Low' press the 'ALT' Key and the 'L' key at the same time." + Environment.NewLine 
    + "In order to reduce the bet's value in half  press the 'ALT' Key and the 'H' key at the same time."); }
    
-------------------

이것도 할 수 있습니다.

        List<string> ListMessage = new List<string>();
        ListMessage.Add("In order to bet 'High' press the 'ALT' Key and the 'H' key at the same time.");
                ListMessage.Add("In order to bet 'Low' press the 'ALT' Key and the 'L' key at the same time.");
                        ListMessage.Add("In order to reduce the bet's value in half  press the 'ALT' Key and the 'H' key at the same time.");
                        
                                //Solution 1
                                        MessageBox.Show(string.Join(Environment.NewLine, ListMessage));
                                        
                                                //Solution 2 => Add using System.Linq
                                                        MessageBox.Show(ListMessage.Aggregate((x, y) => x + Environment.NewLine + y));
                                                        


출처
https://stackoverflow.com/questions/39940127