Unavailability of System.Drawing Image Class

0

This class is not available.

System.Drawing.Image;

I use Vs 2013 and NetFramework 4.5.2 and dll system.drawing v.4.0

I have already added the references and already included a new "dll" and it is not available.

Only declaring System.Drawing already works.

    
asked by anonymous 25.04.2017 / 21:05

1 answer

1

If you want to use this class in the namespace , you'll need to define an Alias for it.

After this, you can do the following:

using System;
using System.Drawing;
using System.Windows.Forms;
using meuAlias = System.Drawing.Image;

namespace Imagem {
    public partial class TesteImagem : Form {
        public TesteImagem() {
            //Construtor
        }

        public void MeuMetodo() {
            //Acessando diretamente a classe com o caminho completo
            var imagem1 = System.Drawing.Image.FromFile("c:\teste.bmp");

            //Usando o Alias criado no Namespace
            var imagem2 = meuAlias.FromFile("c:\teste.jpg");
        }
    }
}

Remembering that namespace simplifies encoding, you do not need them if you always use full names. See, we can directly access this Range method, which is in the Enumerable class, which in turn is in the Linq namespace:

var teste = System.Linq.Enumerable.Range(0, 10);

Recommended readings
Can I use a local alias for class or namespace in C #?

Using the Global Namespace Alias

    
25.04.2017 / 22:27