Reputation: 1
I want to get into this object and make changes.
But when I type the dot, the properties do not open.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
SINIF3 sınıf3 = new SINIF3();
//I want to get into this object and make changes.
//But when I type the dot, the properties do not open.
//For example
//sınıf3.gonder(1).number=2;
Console.ReadKey();
}
}
class DEGER
{
public int number = 1;
}
class SINIF3
{
public object gonder(int a)
{
DEGER objem = new DEGER();
DEGER objem2 = new DEGER();
if (a == 1)
return objem;
else return objem2;
}
}
}
Upvotes: 0
Views: 41
Reputation: 1
Change the the method.
from public object gonder(int a)
to public DEGER gonder(int a)
otherwise you need to cast the object something like sınıf3.((DEGER )gonder(1)).number=2;
But you should try not to return object if you can.
Upvotes: 0
Reputation: 8562
Change the return type of the gonder method from object to DEGER. Of course you're not assigning the result of the gonder method to a variable, so the new object which you change the number field in will be thrown away.
Upvotes: 1