Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
.NET Framework
Passare un valore ad un array di strutture
lunedì 26 marzo 2012 - 14.38
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
C#
|
Windows 7
|
Windows Vista
WinterMute
Profilo
| Newbie
3
messaggi | Data Invio:
lun 26 mar 2012 - 14:38
Buongiorno. Ho definito un array di strutture partendo da una struttura. Non essendo ferratissimo di C# ho curiosato in giro ed ho messo insieme questo codice:
public struct Oggetto // Definisce un oggetto per il layout
{
int a, b, c, d, e, f, g;
Color h;
public Oggetto(int forma, int distanza, int inclinazione, int angolo, int larghezza, int altezza, int profondità, Color colore)
{
a = forma;
b = distanza;
c = inclinazione;
d = angolo;
e = larghezza;
f = altezza;
g = profondità;
h = colore;
}
};
public Oggetto[] layoutObject = new Oggetto [10] // definisce un array 10 oggetti da inserire nel layout
{
//Oggetto(forma, distanza, inclinazione, int angolo, int larghezza, int altezza, int profondità, Color colore)
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
new Oggetto(0, 10, 0, 0, 10, 10, 10, Color.Red),
};
fino a qui non ho errori
Però non riesco a passare un valore agli oggetti dell'array. Vorrei un tipo di istruzione del tipo layoutObject[1].colore = Color.Blue , ma non riesco...
Grazie in anticipo
andrestu
Profilo
| Expert
772
messaggi | Data Invio:
lun 26 mar 2012 - 17:14
devi definire public i membri della struct oggetto.
Andrea Restucci - Web Developer
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !