【发布时间】:2017-03-30 21:49:28
【问题描述】:
我想从不同的类中调用一个对象并改变它的属性。
我想进入这个对象并进行更改。
但是当我键入点时,属性没有打开。
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;
}
}
}
【问题讨论】:
-
也许这只是示例代码,但您的
SINIF3.gonder()方法可以简化为:public DEGER gonder() { return new DEGER(); }