Napomena
Pristup ovoj stranici zahteva autorizaciju. Možete pokušati da se prijavite ili da promenite direktorijume.
Pristup ovoj stranici zahteva autorizaciju. Možete pokušati da promenite direktorijume.
Cannot initialize a by-value variable with a reference
The following sample generates CS8171:
// CS8171.cs (8,13)
class Test
{
void A()
{
int a = 123;
ref int x = ref a;
var y = ref x;
}
}
Remember that var y = ref x
is implicitly int y = ref x
where int y
is a by-value variable.
Removing the ref
modifier from the right side of the assignment will correct this error:
class Test
{
void A()
{
int a = 123;
ref int x = ref a;
var y = x;
}
}
Povratne informacije za .NET
.NET je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije: