Skip to content

Instantly share code, notes, and snippets.

@nodlAndHodl
Last active March 23, 2019 03:44
Show Gist options
  • Select an option

  • Save nodlAndHodl/ee5ccf1171106cea4bf2a2f2283a77ea to your computer and use it in GitHub Desktop.

Select an option

Save nodlAndHodl/ee5ccf1171106cea4bf2a2f2283a77ea to your computer and use it in GitHub Desktop.
class GenericClass<T> where T : class
{
private T _genericField;
public T genericProperty { get; set; }
public GenericClass(T value)
{
_genericField = value;
}
public T genericMethod(T genericParameter)
{
this.genericProperty = genericParameter;
Console.WriteLine("Parameter type: {0}, value: {1}", typeof(T).ToString(), genericParameter);
Console.WriteLine("Return type: {0}, value: {1}", typeof(T).ToString(), this._genericField);
return this._genericField;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment