"The type 'string' must be a non-nullable and generic method"
<p>I have few questions in the following method. Can an expert help me to understand the structure and why I am getting the error?</p>

<p>I have this method that will get a xml element, search the attribute specified in name parameter and case is can't find in the xml, it returns the default value:</p>

<pre><code>protected static T GetValue&lt;T&gt;(XElement group, string name, T default)     where T : struct
{
            //Removed some code for better view
            XAttribute setting = group.Attribute(name);
            return setting == null ? default: (T)Enum.Parse(typeof(T), setting.Value);
}
</code></pre>

<p>My questions is about the generic types used in this method. When I try to use this method in a string variable, I get the following error:</p>

<blockquote>
  <p>string test = GetValue(element, "search", "default value");
      The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'GetValue(XElement, string, T)'    </p>
</blockquote>

<p>What T is this method it the issue that I am getting that error? What does where T : struct mean? I tried to use this as GetValue and it did not work as well...</p>

<p>Any help are really welcome! Thanks!</p>