0

when I was using Xamarin.Essentials, I needed to add an assembly reference. What is the difference between them? I though both were references. Thanks!

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
mx1txm
  • 139
  • 2
  • 10

1 Answers1

1

If an assembly A references an assembly B, then A can use all public types that are contained in B. So it's all about making the contents of another assembly known to your assembly.

The using keyword is used within source files to conveniently allow you to refer to types within a certain namespace without having to specify their full name.

You can access any type without using by specifying their full name like

void MyMethod()
{
    var myList = new System.Collections.Generic.List<int>();
}

But if you put a using statement into your source, you can refer to the type more easily like

using System.Collections.Generic;

void MyMethod()
{
    var myList = new List<int>();
}

So using is really only a convenience feature to make your code more easily written and read.

Thomas Hilbert
  • 3,559
  • 2
  • 13
  • 33