Skip to content

How to do pluralization for structs #295

Answered by axunonb
AnomalousUnderdog asked this question in Q&A
Discussion options

You must be logged in to vote

You can't have a Dice class instance as an argument to SmartFormat without including the properties that SmartFormat should evaluate in the format string. Hope this makes the missing part clear:

using NUnit.Framework;
namespace SmartFormat.Tests.Core;

public struct Dice
{
    /*
     * Original code does not compile - casing of properties
     */

    public int Quantity;
    public int NumberOfSides;
    public int Bonus;

    // new Dice(2, 6, 3) means 2d6+3 meaning roll two 6-sided dice and add 3 to the result
    public Dice(int quantity, int numberOfSides, int bonus)
    {
        Quantity = quantity;
        NumberOfSides = numberOfSides;
        Bonus = bonus;
    }

    public int 

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AnomalousUnderdog
Comment options

@axunonb
Comment options

@AnomalousUnderdog
Comment options

Answer selected by axunonb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants