Question

I am working on MVC 3. The problem is that I want to break the string if its length more then 10. The string value coming from data base as User name. I want to apply that string on a image.. Example

public Image (string Name)
{    
}

so how to break the name string if it is more then 10 char?

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");
    }

Check this out

static void Main(string[] args) {

        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);
        }
    }
Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top