السلام عليكم
انا اولا اعلم ان هذا الموضوع طرح قبل ذلك فى المنتدى و يوجد لة طريقتين للحل
انا بحاول عمل طريقة مشابهة و لكنها لا تعمل
class1
class class1 {
public class1()
{
if (count >= 1)
{
RemoveRef(this);
}
count ++;
}
public static int count = 0;
public string addsomething =" ";
void RemoveRef (class1 ob)
{
ob = null;
}
}Main
class1 ob1 = new class1(); class1 ob2 = new class1(); class1 ob3 = new class1(); ob1.addsomething ="ob1"; ob2.addsomething ="ob2"; ob3.addsomething ="ob3"; Console.WriteLine(ob1.addsomething); // working :) Console.WriteLine(ob2.addsomething); //working :( Console.WriteLine(ob3.addsomething);//working :(
اعتزر اذا وجد اى syntax error لانى مش منزل visual studio