Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing properties by name
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Titre:
Accessing properties by name
Divers
Thread ID:
01652835
Message ID:
01652835
Vues:
43
Hi everybody,

If I have this class
public int LRemoteS1 { get; set; } // LRemoteS1. Layouts.LayoutId of the Salespoint Remote 1 Save
        public int LRemoteF1 { get; set; } // LRemoteF1. Layouts.LayoutId of the Salespoint Remote 1 Finalize
        public int LRemoteS2 { get; set; } // LRemoteS2. Layouts.LayoutId of the Salespoint Remote 2 Save
        public int LRemoteF2 { get; set; } // LRemoteF2. Layouts.LayoutId of the Salespoint Remote 2 Finalize
        public int LRemoteS3 { get; set; } // LRemoteS3. Layouts.LayoutId of the Salespoint Remote 3 Save
        public int LRemoteF3 { get; set; } // LRemoteF3. Layouts.LayoutId of the Salespoint Remote 3 Finalize
I actually have 8 of them and 8 corresponding string properties, is there a way to write code to access them by name in the loop?

E.g.
for (int i=1; i<=8;  i++ )
            {
                if (model.LSummary > 0)
                    model.LSummaryText = _layoutAdapter.GetLayoutName(model.LSummary);
                else
                    model.LSummaryText = _layoutAdapter.GetLayoutName(prefssl == null ? 0 : prefssl.DlSummary);
            }
but instead of the LSummary use LRemoteFi and LRemoteSi instead?

Thanks in advance.

UPDATE. As I thought, it's not worth the trouble, I'll just copy/paste the same code instead

https://stackoverflow.com/questions/2905187/accessing-object-property-as-string-and-setting-its-value
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform