입력

2014-01-17 3 views
1

에 대한 브러쉬 변수를 선언 I 현재 다음과 같은 방법 그러나입력

public void printTitle(string title){ 
    // settings for stringformat 
    g.DrawString(title, drawFontTitle, Brushes.White, x, y, stringFormatTitle); 
} 

, 내가 입력과 같이, 제목의 색상을 정의 할 수 있도록 노력하고 있습니다

public void printTitle(string title, Brushes titleColor){ 
    // settings for stringformat 
    g.DrawString(title, drawFontTitle, titleColor, x, y, stringFormatTitle); 
} 

그리고 다음과 같이 사용됩니다 :

printTitle("Title Text", Brushes.White);

그러나, 내가 생각하는 오류의 원인이되는 Brushes titleColor을 신고 할 때 문제가 발생합니다. 대신이 작동

public void printTitle(string title, Brushes titleColor) 
{ 
    // settings for stringformat 
    g.DrawString(title, drawFontTitle, titleColor, x, y, stringFormatTitle); 
} 

그래서 이것을 사용 :

+0

오류가 무엇입니까? – Jason

+0

당신 (그리고 다른 사람들)은 당신의 이름 옆에있는 [편집 한 ... 이전]] (http://stackoverflow.com/questions/21192097/revisions) 링크를 클릭하여 편집 한 사람을 볼 수 있습니다. 그래서 감사와 다른 소음을 추가 할 필요가 없습니다. ;-) – rene

답변

4

문제는 당신 타입의 브러시이며 당신의 방법은 매개 변수 유형으로 브러쉬를 가지고 Brushes.Color의 가치를 전달하는 것입니다

public void printTitle(string title, Brush titleColor) 
{ 
    // settings for stringformat 
    g.DrawString(title, drawFontTitle, titleColor, x, y, stringFormatTitle); 
} 
+0

고마워요. 또한 코드를 더 쉽게 읽을 수 있도록 포맷했지만 편집을 통해 코드를 만들지 않았습니다. – theGreenCabbage