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