Skip to content

kenanbasdemir/flyweight.indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flyweight Indexer

The Flyweight Pattern is used to increase the production and performance of similar types of objects that are frequently used in memory.

An example of using the flyweight design pattern with an indexer.

Usage/Examples

The following example is the indexer where a keyboard class manages the keys.

public class Key
{
    public string Value { get; set; }
}

public class Keyboard : IndexerBase<Key>
{
    public string KeyboardName { get; set; }
}

static void Main()
{
    Keyboard keyboard = new Keyboard();
    keyboard["k"].Value = "K";
    keyboard["e"].Value = "E";
    keyboard["n"].Value = "N";
    keyboard["a"].Value = "A";

    string firstName = string.Concat(
        keyboard["k"].Value,
        keyboard["e"].Value,
        keyboard["n"].Value,
        keyboard["a"].Value,
        keyboard["n"].Value);

    Console.WriteLine(firstName);
}

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages