-3

MVC 3에서 작업 중입니다. 문제는 길이가 10보다 길면 문자열을 끊는 것입니다. 사용자 이름으로 데이터베이스에서 오는 문자열 값입니다. 나는 그것이 10 문자 후 이상이있는 경우 예길이가 10 자 이상인 경우 줄 바꿈이 발생합니다.

public Image (string Name) 
{  
} 

그래서 어떻게 이름 문자열을 깰에 .. 이미지에 해당 문자열을 적용 할?

public FileResult image(string image) 
    { 



     Bitmap bitMapImage = new Bitmap(Server.MapPath("/Content/themes/base/images/photo.png")); 
     // Bitmap bitMapImage = new Bitmap("/Content/themes/base/images/del02s(1).jpg"); 

     //TODO : comment for revert the cation of no photo 
     Graphics graphicImage = Graphics.FromImage(bitMapImage); 
     graphicImage.SmoothingMode = SmoothingMode.AntiAlias; 
     int count = image.Length; 
     string[] arr4 = new string[count]; 
     if (image.Length > 9) 
     { 

      string imges = image 

     } 

     graphicImage.DrawString(image, new Font("Trebuchet MS,Trebuchet,Arial,sans-serif", 10, FontStyle.Bold), SystemBrushes.WindowFrame, new Point(15, 5)); 


     graphicImage.DrawArc(new Pen(Color.Red, 3), 90, 235, 150, 50, 0, 360); 
     MemoryStream str = new MemoryStream(); 
     bitMapImage.Save(str, ImageFormat.Png); 


     return File(str.ToArray(), "image/png"); 
    } 

확인이 밖으로

정적 무효 메인 (문자열 []에 인수) {

 string image = "1234567890abcdefghijklmnopqrsy"; 
     int count = image.Length; 

     if (image.Length > 9) 
     { 
      //getting Error 
      string img1 = image.Substring(0, 10); 
      string img2 = image.Substring(10, count);//getting Error Index and length   //must refer to a location within the string. 
      //Parameter name: length" 



      string imge3 = img1 + "\n"; 
      string img4 = imge3 + img2; 

      Console.WriteLine(img4); 
     } 
    } 
+0

당신이 게시하려는 경우 질문을 한 다음 시간을내어 읽을 수있게하십시오. 제목에 불필요한 태그를 넣지 말고 철자에주의하십시오. – slugster

+0

나는 이것을했다. – Agha

답변