Reputation: 2164
It is strange....
there is a namespace named Android.Graphics and I'm work in the namespace named Xamarin.FormsBook.Platform.Android.
There is one more namespace named Xamarin.Forms and it has Color field.
Now, I want to use Android.Graphics.Color so I write Color then something recognize it as Xamarin.Forms.Color not Android.Graphics.Color.
And, If I write Android.Graphics.Color the builder could not find Android.Graphics. If I write Android. then builder find Xamarin.FormsBook.Platform.Android 's methods and fields.
If I write Android.Graphics.Color outside of namespace region, then it recognize.
But I can't assign any value in it since 'A namespace can not directly contain members such as fields or methods'.
help me, I want to use Color of Android.Graphic
Upvotes: 0
Views: 34
Reputation: 6823
You can do this by using an alias directive:
using AndroidGraphics = Android.Graphics;
You can then refer to the Android.Graphics.Color
type by using the alias name AndroidGraphics.Color
. Since there isn't another namespace called AndroidGraphics
your compiler will resolve it correctly.
Alias directives can also be used for individual types, so you could also do the following:
using AndroidColor = Android.Graphics.Color;
and then refer to the type using AndroidColor
.
Upvotes: 1