Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi!

Ich habe folgendes Problem:

Ich erstelle ein Struct:


    public struct CommandStruct

    {

        public string aCategory; // Eine Category kann mehrere Commands haben.

        public string aCommand;  // Ein Command kann nur eine Category haben. (Jedes Command ist eingigartig)

        public string aShortcut; // Ein Shortcut kann nur zu einem Command gehören.

        public string aToolTip;  // Mehrere Commands können einen gleichen ToolTip haben.

        public image aImage;     // Mehrere Commands können sich ein Image teilen.

    }

Nun mache ich mir eine Liste daraus:

List<CommandStruct> m_CommandStructList = new List<CommandStruct>();

Ich möchte nun zum Beispiel folgendes wissen:

Ich habe eine Category und das dazugehörige Command. Nun möchte ich den ShortCut dazu wissen.

Anderes Beispiel:

Ich habe eine Category und möchte die jeweiligen Commands dazu wissen.

Kann ich das mit der Liste machen?

Wenn nicht: Gibt es einen anderen (besseren) Weg?

Habe es auch mal mit mehreren Dictionarys probiert. Das hat aber den Nachteil das man immer nur einen Key und ein Value hat.

Sorry falls es ein wenig kompliziert geschrieben ist. :hells:

Gruß Nightfall

class Program
{
public struct CommandStruct
{
public string aCategory; // Eine Category kann mehrere Commands haben.
public string aCommand; // Ein Command kann nur eine Category haben. (Jedes Command ist eingigartig)
public string aShortcut; // Ein Shortcut kann nur zu einem Command gehören.
public string aToolTip; // Mehrere Commands können einen gleichen ToolTip haben.
public string aImage; // Mehrere Commands können sich ein Image teilen.
}


static void Main(string[] args)
{
List<CommandStruct> m_CommandStructList = new List<CommandStruct>();
m_CommandStructList.Add(new CommandStruct() { aCategory = "Cat1", aCommand = "Com1", aShortcut = "Strg+A", aImage = "Image1", aToolTip = "fdbgio" });
m_CommandStructList.Add(new CommandStruct() { aCategory = "Cat1", aCommand = "Com2", aShortcut = "Strg+B", aImage = "Image2", aToolTip = "fdbgfhrjio" });
m_CommandStructList.Add(new CommandStruct() { aCategory = "Cat2", aCommand = "Com3", aShortcut = "Strg+C", aImage = "Image1", aToolTip = "trh" });
m_CommandStructList.Add(new CommandStruct() { aCategory = "Cat2", aCommand = "Com4", aShortcut = "Strg+D", aImage = "Image2", aToolTip = "fdbgio" });
m_CommandStructList.Add(new CommandStruct() { aCategory = "Cat2", aCommand = "Com5", aShortcut = "Strg+E", aImage = "Image1", aToolTip = "fdbfjjgio" });

var shortcut = from com in m_CommandStructList
where com.aCategory == "Cat1" && com.aCommand == "Com2"
select com.aShortcut;
Console.WriteLine(shortcut.First());


var commands = from com in m_CommandStructList
where com.aCategory == "Cat2"
select com;

foreach (CommandStruct cs in commands)
{
Console.WriteLine(cs.aCommand);
}
}
}[/PHP]

Habe es auch mal mit mehreren Dictionarys probiert. Das hat aber den Nachteil das man immer nur einen Key und ein Value hat.

List<CommandStruct> als Value?! :floet:

Aber ich denke das Linq-Beispiel vom Piraten ist da performanter, einfacherer usw.

Ganz großes danke schön an den Piraten. :uli

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.