Difference between revisions of "Dice/Roller/Roll (String, RollerConfig)"
From DiceRoller Documentation
| Line 5: | Line 5: | ||
<syntaxhighlight lang="C#"> | <syntaxhighlight lang="C#"> | ||
public static RollResult Roll( | public static RollResult Roll( | ||
| − | string diceExpr | + | string diceExpr, |
| + | RollerConfig config = null | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 13: | Line 14: | ||
: Type: System.String | : Type: System.String | ||
: A [[Dice Reference|dice expression]]. | : A [[Dice Reference|dice expression]]. | ||
| + | ; ''config'' | ||
| + | : Type: [[API/RollerConfig|Dice.RollerConfig]] | ||
| + | : Configuration to use for this roll. If {{cs|null}}, the [[API/Roller/DefaultConfig|DefaultConfig]] will be used. | ||
=== Return value === | === Return value === | ||
Revision as of 16:41, 8 April 2017
Rolls dice according to the given dice expression. Please see Dice Reference for more information about dice expressions.
Syntax
public static RollResult Roll(
string diceExpr,
RollerConfig config = null
)
Parameters
- diceExpr
- Type: System.String
- A dice expression.
- config
- Type: Dice.RollerConfig
- Configuration to use for this roll. If
null, the DefaultConfig will be used.
Return value
Type: Dice.RollResult
The result of rolling diceExpr.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentNullException | diceExpr is null.
|
| DiceException | An error was detected with diceExpr. |
When a DiceException is thrown, the exception will contain an ErrorCode property which describes the error in more detail.
Example
RollResult result = Roller.Roll("1d20+4");
Console.WriteLine(result.Value);