If you want to use this class (Image) in namespace, will have to define a Alias for her.
After that, 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 the namespace serve to simplify coding, do not need them if always use full names.
See, we can directly access this method Range
, who’s in class Enumerable
, which in turn is in the namespace Linq:
var teste = System.Linq.Enumerable.Range(0, 10);
Recommended readings
In C# it is possible to use a local alias for class or namespace?
How to use global namespace alias
What type of project? What are you trying to do with the code shown above? Declare a variable or make an import (using)?
– Jéf Bueno
@jbueno using was trying.
– Daniel