02 Eyl

Convert Image To Byte Array in C#

This example shows how to convert an image into a byte array.

Sample Code:

        public byte[] ImageToByteArray(Image img)
        {
            MemoryStream ms = new MemoryStream();
            img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            return ms.ToArray();
        }

See Also:
Convert Byte Array To Image

02 Eyl

Convert Byte Array To Image in C#

This example shows how to convert a byte array into an image.

Sample Code:

        public Image ByteArrayToImage(byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            Image returnImage = Image.FromStream(ms);
            return returnImage;
        }

See Also:
Convert Image To Byte Array

22 Ağu

Bootstrap Panel Samples

This example shows how to create a panel using bootstrap framework.

Firstly, you should add the following code to the head section in html:

  https://csharpexamples.com
  
  
  
  

Sample Usage :

    
Simple panel without heading
Sample 1
Panel Content 1
Sample 2
Panel Content 2
Sample 3
Panel Content 3
Sample 4
Panel Content 4
Sample 5
Panel Content 5
Sample 6
Panel Content 6

RESULT :
bootstrap panel samples

22 Ağu

Bootstrap Pagination Samples

Pagination is the process of dividing the content into discrete pages, either electronic pages or printed pages. These examples show how to make pagination using bootstrap framework.

Firstly, you should add the following code to the head section in html:

  https://csharpexamples.com
  
  
  
  

SAMPLE USAGES :

Pagination with Disabled and Active States :

     

RESULT :
Bootstrap Pagination

Pager Sample :

    

RESULT :
Bootstrap pager

22 Ağu

C# Try-Catch-Finally Usage For Exception Handling

This example shows how to use a try-catch statement for exception handling.

Sample Usage:

            try
            {
                //Do something
            }
            catch(Exception ex)
            {
                //Handle exception
            }
            finally
            {
                //This code is always executed 
            }