0
所以,我有這個class和struct:如何使用對象的公共結構的一類
class CarCollection
{
//struct contenant les informations pour décrire une voiture de la collection
public struct voiture
{
public string marque, couleur, condition;
public int annee;
public DateTime dateAcquisition, dateVente;
public double prix;
}
...
我要的是能夠創造這個結構中的類型的變量類我有包含此結構的對象:
class Program
{
static CarCollection collection;
...
voiture temp = new voiture();
//or
collection.voiture temp = new collection.voiture();
我該如何做到這一點?
試試'new CarCollection.voiture()'。 – adrianbanks
注意:您的結構不代表一個實體,它大於16個字節,並且不可變。考慮改爲使用類。 – Guffa
這是明確指出的assignement所以我沒有選擇... – AntoineLev