# GrapeCity.CalcEngine.FunctionResolver.AddFunction

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_CalcEngine_FunctionResolver_AddFunction_" data-uid="GrapeCity.CalcEngine.FunctionResolver.AddFunction*">AddFunction Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_CalcEngine_FunctionResolver_AddFunction_" data-uid="GrapeCity.CalcEngine.FunctionResolver.AddFunction*"></a>
<h4 id="GrapeCity_CalcEngine_FunctionResolver_AddFunction_GrapeCity_CalcEngine_Function_" data-uid="GrapeCity.CalcEngine.FunctionResolver.AddFunction(GrapeCity.CalcEngine.Function)">AddFunction(Function)</h4>
<div class="markdown level1 summary"><p>Adds a new user-defined custom function to the model for use in formulas.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddFunction(Function function)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddFunction([function] As [Function])</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.CalcEngine.Function.html">Function</a></td>
      <td><span class="parametername">function</span></td>
      <td><p>Specifies the user-defined Function object to add</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_CalcEngine_FunctionResolver_AddFunction_GrapeCity_CalcEngine_Function__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>User-defined Function class must be marked with the Serializable attribute
or an exception occurs if the data model is saved to view state, a file, or otherwise serialized.</p>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></td>
      <td><p>No function is specified; function is a null reference (Nothing in Visual Basic)</p>
</td>
    </tr>
  </tbody>
</table>
</div>
