I'm not sure how to create a list of objects. I get "Non-invocable member ListObjects.TestObject.UniqueID' cannot be used like a method."
Any insight would be helpful.
The code for the object I'm trying to create a list of:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ListObjects
{
class TestObject
{
public int UniqueID { get; set; }
}
}
Main code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ListObjects
{
class Program
{
static void Main(string[] args)
{
TestObject TestObject = new TestObject();
List<TestObject> ObjectList = new List<TestObject>();
ObjectList.Add(new TestObject().UniqueID(1));
ObjectList.Add(new TestObject().UniqueID(10));
ObjectList.Add(new TestObject().UniqueID(39));
}
}
}
new TestObject().UniqueID(1));- should benew TestObject().UniqueID = 1;UniqueIDis a property, not a method, and in the original code it's being used like a method.