Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 21, 2014 23:19
Show Gist options
  • Save Fhernd/96caa28f153166d942e6 to your computer and use it in GitHub Desktop.
Save Fhernd/96caa28f153166d942e6 to your computer and use it in GitHub Desktop.
Intento de asignación de nueva instancia a this en un miembro función de una clase.
using System;
namespace Articulos.Preguntas
{
public class UsoThisEnClase
{
private int campo;
public UsoThisEnClase(int valor)
{
this.campo = valor;
}
public void Metodo(int a)
{
this.campo = a;
this = new UsoThisEnClase(9);
Console.WriteLine(campo.ToString());
}
public static void Main()
{
UsoThisEnClase ut = new UsoThisEnClase(3);
ut.Metodo(4);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment